FromLixSchemaDefinition<
T> =ApplyLixGenerated<T>
Convert a LixSchemaDefinition to a TypeScript type.
This type transformation:
default or x-lix-default) in LixGenerated markerstype: "object" without properties to Record<string, any>The resulting type can be used with LixInsertable, LixUpdateable, and LixSelectable for database operations.
const AccountSchema = {
"x-lix-key": "account",
"x-lix-version": "1.0",
"x-lix-primary-key": ["/id"],
type: "object",
properties: {
id: { type: "string", default: "auto-generated" },
name: { type: "string" },
email: { type: "string" },
metadata: { type: "object" }, // Becomes Record<string, any>
created_at: { type: "string", "x-lix-default": "lix_now()" }
},
required: ["id", "name", "email"],
additionalProperties: false
} as const satisfies LixSchemaDefinition;
type Account = FromLixSchemaDefinition<typeof AccountSchema>;
// Result: {
// id: LixGenerated<string>;
// name: string;
// email: string;
// metadata: Record<string, any> | undefined;
// created_at: LixGenerated<string> | undefined;
// }| Type Parameter |
|---|
T extends LixSchemaDefinition |