createEntityViewsIfNotExists(
args
: {defaultValues?
:Record
<string
, () =>any
| (row
:Record
<string
,any
>) =>any
>;engine
:Pick
<LixEngine
,"sqlite"
>;hardcodedFileId?
:string
;hardcodedVersionId?
:string
;overrideName?
:string
;pluginKey
:string
;readOnly?
:boolean
;schema
:LixSchemaDefinition
;validation?
:ValidationCallbacks
; }):void
Creates SQL views and CRUD triggers for an entity based on its schema definition.
This function automatically generates three views:
Each view includes:
Parameter | Type | Description |
---|---|---|
args | { defaultValues? : Record <string , () => any | (row : Record <string , any >) => any >; engine : Pick <LixEngine , "sqlite" >; hardcodedFileId? : string ; hardcodedVersionId? : string ; overrideName? : string ; pluginKey : string ; readOnly? : boolean ; schema : LixSchemaDefinition ; validation? : ValidationCallbacks ; } | - |
args.defaultValues? | Record <string , () => any | (row : Record <string , any >) => any > | Object mapping property names to functions that generate default values |
args.engine | Pick <LixEngine , "sqlite" > | - |
args.hardcodedFileId? | string | Optional hardcoded file_id (if not provided, uses lixcol_file_id from mutations) |
args.hardcodedVersionId? | string | Optional hardcoded version_id (if not provided, uses lixcol_version_id from mutations or active version) |
args.overrideName? | string | Overrides the view name which defaults to schema["x-lix-key"] |
args.pluginKey | string | Plugin identifier for the entity |
args.readOnly? | boolean | If true, creates read-only views (no INSERT/UPDATE/DELETE triggers) |
args.schema | LixSchemaDefinition | - |
args.validation? | ValidationCallbacks | Custom validation logic for entity operations |
void
Error if schema type is not "object" or x-lix-primary-key is not defined