Type Alias: LixInsertable<T>

LixInsertable<T> = { [K in NonNullableInsertKeys<T>]: InsertType<T[K]> } & { [K in NullableInsertKeys<T>]?: InsertType<T[K]> }

Transform a type for insert operations.

This type makes LixGenerated fields optional while keeping other required fields mandatory. Use this when defining types for creating new entities.

The database will automatically populate generated fields (like IDs, timestamps) if not provided.

Type Parameters

T

T

Example

type Account = {
  id: LixGenerated<string>;
  name: string;
  email: string;
  created_at: LixGenerated<string>;
};

type NewAccount = LixInsertable<Account>;
// Result: { name: string; email: string; id?: string; created_at?: string; }

const account: NewAccount = {
  name: "John",
  email: "john@example.com"
  // id and created_at are optional
};