Function: ebEntity()

ebEntity<TB>(entityType?: TB): { equals: (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>; hasLabel: (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>; in: (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>; }

Entity Expression Builder - provides fluent API for entity operations in queries.

This allows for more readable query syntax like: .where(ebEntity("file").hasLabel({ name: "important" })) .where(ebEntity("state").equals(userAccount)) .where(ebEntity().in(entities)) // When context is unambiguous (no joins)

Type Parameters

Type ParameterDefault type
TB extends "key_value" | "key_value_all" | "key_value_history" | "account" | "account_all" | "account_history" | "change_set" | "change_set_all" | "change_set_history" | "change_set_element" | "change_set_element_all" | "change_set_element_history" | "change_set_label" | "change_set_label_all" | "change_set_label_history" | "change_author" | "change_author_all" | "change_author_history" | "file" | "file_all" | "file_history" | "label" | "label_all" | "label_history" | "state" | "entity_label" | "entity_label_all" | "entity_label_history" | "entity_thread" | "entity_thread_all" | "entity_thread_history" | "version" | "stored_schema" | "stored_schema_all" | "stored_schema_history" | "log" | "log_all" | "log_history" | "thread" | "thread_all" | "thread_history" | "thread_comment" | "thread_comment_all" | "thread_comment_history" | "version_all" | "version_history" | "commit" | "commit_all" | "commit_history" | "commit_edge" | "commit_edge_all" | "commit_edge_history" | "active_account" | "active_version" | "state_all" | "state_with_tombstones" | "state_history" | "change""key_value" | "key_value_all" | "key_value_history" | "account" | "account_all" | "account_history" | "change_set" | "change_set_all" | "change_set_history" | "change_set_element" | "change_set_element_all" | "change_set_element_history" | "change_set_label" | "change_set_label_all" | "change_set_label_history" | "change_author" | "change_author_all" | "change_author_history" | "file" | "file_all" | "file_history" | "label" | "label_all" | "label_history" | "state" | "entity_label" | "entity_label_all" | "entity_label_history" | "entity_thread" | "entity_thread_all" | "entity_thread_history" | "version" | "stored_schema" | "stored_schema_all" | "stored_schema_history" | "log" | "log_all" | "log_history" | "thread" | "thread_all" | "thread_history" | "thread_comment" | "thread_comment_all" | "thread_comment_history" | "version_all" | "version_history" | "commit" | "commit_all" | "commit_history" | "commit_edge" | "commit_edge_all" | "commit_edge_history" | "active_account" | "active_version" | "state_all" | "state_with_tombstones" | "state_history" | "change"

Parameters

ParameterTypeDescription
entityType?TBThe type of entity table being queried (e.g., "file", "account", "thread"). Optional when the context is unambiguous (e.g., single table queries with no joins).

Returns

equals()

equals(entity: LixEntityCanonical | LixEntity): (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Creates a filter that matches entities equal to the specified entity.

Example

await lix.db.selectFrom("account")
     .where(ebEntity("account").equals(targetAccount))
     .selectAll()
     .execute();

Parameters

ParameterTypeDescription
entityLixEntityCanonical | LixEntityThe entity to match against (must have entity_id, schema_key, file_id)

Returns

Expression wrapper for use in WHERE clauses

(eb: ExpressionBuilder<LixDatabaseSchema, TB>): ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Parameters
ParameterType
ebExpressionBuilder<LixDatabaseSchema, TB>
Returns

ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

hasLabel()

hasLabel(label: { id: string; name?: string; } | { id?: string; name: string; }): (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Creates a filter that matches entities having the specified label.

Example

await lix.db.selectFrom("file")
     .where(ebEntity("file").hasLabel({ name: "important" }))
     .selectAll()
     .execute();

Parameters

ParameterTypeDescription
label{ id: string; name?: string; } | { id?: string; name: string; }The label to filter by (either { name: "..." } or { id: "..." })

Returns

Expression wrapper for use in WHERE clauses

(eb: ExpressionBuilder<LixDatabaseSchema, TB>): ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Parameters
ParameterType
ebExpressionBuilder<LixDatabaseSchema, TB>
Returns

ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

in()

in(entities: ({ entity_id: string; file_id: string; schema_key: string; } | { lixcol_entity_id: string; lixcol_file_id: string; lixcol_schema_key: string; })[]): (eb: ExpressionBuilder<LixDatabaseSchema, TB>) => ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Creates a filter that matches entities in the specified list.

Example

await lix.db.selectFrom("thread")
     .where(ebEntity("thread").in([thread1, thread2, thread3]))
     .selectAll()
     .execute();

Parameters

ParameterTypeDescription
entities({ entity_id: string; file_id: string; schema_key: string; } | { lixcol_entity_id: string; lixcol_file_id: string; lixcol_schema_key: string; })[]Array of entities to match against

Returns

Expression wrapper for use in WHERE clauses

(eb: ExpressionBuilder<LixDatabaseSchema, TB>): ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>

Parameters
ParameterType
ebExpressionBuilder<LixDatabaseSchema, TB>
Returns

ExpressionWrapper<LixDatabaseSchema, TB, SqlBool>