Type Alias: NewState<T>

NewState<T> = LixInsertable<EntityStateView<T>>

Type for creating new entities in the active version.

This type makes all LixGenerated columns optional (like id, timestamps), while keeping other required fields mandatory. The database will automatically populate generated fields if not provided.

Type Parameters

T

T

Example

// Use NewState for form data types
interface SettingsFormData {
  setting: NewState<KeyValue>;
}

async function createSetting(formData: SettingsFormData) {
  // Only key and value are required
  const newSetting: NewState<KeyValue> = {
    key: formData.setting.key,
    value: formData.setting.value
    // lixcol_created_at, lixcol_file_id etc. are auto-generated
  };

  await lix.db
    .insertInto("key_value")
    .values(newSetting)
    .execute();
}