Rename a field without orphaning existing data
Use renameTo and a safe default while documents migrate lazily to a new field name.
Use renameTo and a safe default while documents migrate lazily to a new field name.
Use this when
- rename a field safely
- change a field name without losing data
- migrate an existing schema
- keep old documents working after a rename
Dyrected concepts
renameTo, defaultValue, schema evolution
Additional packages: No additional packages.
Decisions and cautions
Use this recipe only when its runtime matches the project you are documenting or building. Cloud recipes must stay inside the managed content backend boundary. Self-hosted recipes may use the server runtime, database, hooks, and infrastructure you control.
Complete recipe
This is the canonical source compiled and behavior-tested by @dyrected/knowledge.
import { defineCollection, defineTextField } from "@dyrected/core";
export const Customers = defineCollection({
slug: "customers",
fields: [
defineTextField({
name: "fullName",
label: "Full name",
renameTo: "name",
defaultValue: "",
required: true,
}),
],
});Calculate field values and format strings live
Automatically calculate prices, format reference codes, and transform field values in real time without custom JavaScript functions.
Show an Admin field only when it is relevant
Use a serializable Admin condition to reveal a field from the editor's current form values.