Repository
Defined in: repository.ts:90
A thin, database-agnostic data-access layer for a single protobuf message type. Handles serialization, filtering, field masking, and etag generation so callers work with strongly-typed messages.
Type Parameters
Section titled “Type Parameters”Desc extends DescMessage
Properties
Section titled “Properties”schema
Section titled “schema”
readonlyschema:Desc
Defined in: repository.ts:92
The protobuf message descriptor this repository manages.
tableName
Section titled “tableName”
readonlytableName:string
Defined in: repository.ts:95
The database table or collection name.
Methods
Section titled “Methods”batchCreate()
Section titled “batchCreate()”batchCreate(
resources,options?):Promise<MessageShape<Desc>[]>
Defined in: repository.ts:190
Create multiple resources atomically. All resources are validated before any writes occur. If any validation fails, no resources are created.
Parameters
Section titled “Parameters”resources
Section titled “resources”MessageInitShape<Desc>[]
The fully-formed messages to insert.
options?
Section titled “options?”Optional read mask, validateOnly, and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>[]>
Throws
Section titled “Throws”If any resource with the same IDENTIFIER fields already exists.
batchDelete()
Section titled “batchDelete()”batchDelete(
queries,options?):Promise<void>
Defined in: repository.ts:222
Delete multiple resources atomically. All resources must exist — if any is missing, a NotFoundError is thrown and no resources are deleted.
Parameters
Section titled “Parameters”queries
Section titled “queries”QueryInput<Desc>[]
An array of AIP-160 filter strings or partial resource objects identifying the resources to delete.
options?
Section titled “options?”Optional validateOnly and transaction.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If any resource is not found.
batchGet()
Section titled “batchGet()”batchGet(
queries,options?):Promise<MessageShape<Desc>[]>
Defined in: repository.ts:177
Retrieve multiple resources matching the given queries. All resources must exist — if any is missing, a NotFoundError is thrown and no partial results are returned.
Results are returned in the same order as the input queries.
Parameters
Section titled “Parameters”queries
Section titled “queries”QueryInput<Desc>[]
An array of AIP-160 filter strings or partial resource objects.
options?
Section titled “options?”Optional read mask and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>[]>
Throws
Section titled “Throws”If any matching resource is not found.
batchUpdate()
Section titled “batchUpdate()”batchUpdate(
updates,options?):Promise<MessageShape<Desc>[]>
Defined in: repository.ts:206
Update multiple existing resources atomically. Each update item specifies the query to identify the resource, the fields to update, and an optional per-item update mask.
Parameters
Section titled “Parameters”updates
Section titled “updates”BatchUpdateItem<Desc>[]
The update items, each with query, resource, and optional updateMask.
options?
Section titled “options?”Optional read mask, validateOnly, and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>[]>
Throws
Section titled “Throws”If any resource is not found.
count()
Section titled “count()”count(
query?,options?):Promise<number>
Defined in: repository.ts:162
Count resources matching an optional query.
Parameters
Section titled “Parameters”query?
Section titled “query?”QueryInput<Desc>
An AIP-160 filter string, a partial resource object,
or undefined to count all resources.
options?
Section titled “options?”Optional transaction.
Returns
Section titled “Returns”Promise<number>
create()
Section titled “create()”create(
resource,options?):Promise<MessageShape<Desc>>
Defined in: repository.ts:116
Create a new resource. The message is serialized, an etag is computed (if the schema has an etag field), and the row is inserted into the database.
Parameters
Section titled “Parameters”resource
Section titled “resource”MessageInitShape<Desc>
The fully-formed message to insert.
options?
Section titled “options?”Optional read mask and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>>
delete()
Section titled “delete()”delete(
query,options?):Promise<void>
Defined in: repository.ts:153
Delete a resource matching the query.
Parameters
Section titled “Parameters”QueryInput<Desc>
An AIP-160 filter string or partial resource to identify the resource to delete.
options?
Section titled “options?”Optional transaction.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If no matching resource is found.
get(
query,options?):Promise<MessageShape<Desc>>
Defined in: repository.ts:106
Retrieve a single resource matching the query.
Parameters
Section titled “Parameters”QueryInput<Desc>
An AIP-160 filter string or a partial resource object.
Partial objects are converted to equality filters
(e.g. { uid: "abc" } → uid = "abc").
options?
Section titled “options?”Optional read mask and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>>
Throws
Section titled “Throws”If no matching resource is found.
list()
Section titled “list()”list(
query?,options?):Promise<ListResult<Desc>>
Defined in: repository.ts:126
List resources matching an optional query with pagination and ordering support.
Parameters
Section titled “Parameters”query?
Section titled “query?”QueryInput<Desc>
An AIP-160 filter string, a partial resource object,
or undefined to match all resources.
options?
Section titled “options?”Pagination, ordering, read mask, and transaction.
Returns
Section titled “Returns”Promise<ListResult<Desc>>
update()
Section titled “update()”update(
query,resource,options?):Promise<MessageShape<Desc>>
Defined in: repository.ts:139
Update an existing resource. The resource is fetched, merged with the update according to the update mask, and persisted. An etag is recomputed if the schema has an etag field.
Parameters
Section titled “Parameters”QueryInput<Desc>
An AIP-160 filter string or partial resource to identify the resource to update.
resource
Section titled “resource”MessageInitShape<Desc>
The fields to update.
options?
Section titled “options?”Update mask, read mask, validateOnly, and transaction.
Returns
Section titled “Returns”Promise<MessageShape<Desc>>
Throws
Section titled “Throws”If no matching resource is found.