Data Lifecycle
Application patterns for slugs, validation, and schema changes that need to stay safe as content changes over time.
Use these patterns when the hard part is not the initial schema, but keeping data safe and predictable as editors create, update, and evolve content. They help protect URL structure, catch invalid changes, and handle schema evolution more carefully.
For Cloud, prefer lifecycle patterns that can be expressed as schema data: Jexl-style hooks, access rules, field defaults, and content modeling choices. Function hooks, database migrations, and arbitrary after-save side effects belong in self-hosted Dyrected unless a Cloud-specific surface says otherwise.
Generate a slug from a title
Problem: you want readable URLs, but you do not want editors hand-authoring slugs for every document.
This pattern generates the slug on the server and can also mirror it live in the Admin UI. It is a strong default for article pages, documentation content, and any collection that needs stable URL-friendly paths.
Example implementation
[!TIP] You can use Dyrected's built-in Jexl helper functions—such as
slugify(siblingData.title)orlower(siblingData.name)—directly in declarative string hooks for 100% Cloud-safe live field derivation.
Read the full docs:
Validate related fields before saving
Problem: one field value is only valid in relation to another field, such as a start date and an end date.
This pattern uses a collection hook to reject invalid combinations before they reach the database. It is a good fit for dates, time windows, numeric ranges, and any rule that depends on multiple values together.
Example implementation
Read the full docs:
Rename a field without orphaning existing data
Problem: you need to change a field name on a live schema without breaking the documents that already exist.
This pattern uses renameTo and a safe default so old content can continue working while the schema migrates. It is the safer path when a schema needs to evolve without forcing a risky big-bang rename.
Example implementation
import { defineCollection, defineTextField } from "@dyrected/core";
export const Customers = defineCollection({
slug: "customers",
fields: [
defineTextField({
name: "fullName",
label: "Full name",
renameTo: "name",
defaultValue: "",
required: true,
}),
],
});
Read the full docs:
Archive records instead of deleting them
Problem: content should disappear from normal views without being permanently deleted from the database.
This pattern adds an archive flag, hides archived rows from normal readers, and disables destructive deletion. It is useful for announcements, listings, or internal records that may need to be restored or audited later.
Example implementation
Read the full docs: