run instruction for advanced use cases.Schema Management
updateSchema: Create or update a collection schema
updateSchema: Create or update a collection schema
createdAt, updatedAt, createdBy, and updatedBy fields.listCollections: List all collections
listCollections: List all collections
getCollectionSchemas: Get all schemas
getCollectionSchemas: Get all schemas
getCollectionStats: Get collection statistics
getCollectionStats: Get collection statistics
inferCollectionSchema: Infer schema from data
inferCollectionSchema: Infer schema from data
collection or data.deleteCollections: Delete collections
deleteCollections: Delete collections
getSchemaDrift: Compare tables with their schema
getSchemaDrift: Compare tables with their schema
declaredIn). Reads only, and only the
tables of the caller’s workspace (or app).drift is always false.runSchemaMigrations: Convert columns of a collection
runSchemaMigrations: Convert columns of a collection
workspaces.collections.migrated and workspaces.collections.notMigrated
events. Returns applied, failed, skipped (columns left alone, with
howTo convert them) and rolledBack. If the synchronization fails, the
conversions are rolled back and the error details list them.With dryRun: true, nothing is converted and the table is not locked
against reads: planned lists what would run (cast, rows, retyped).
The schema is validated as the real run would, but the synchronization that
follows the conversions is not tried: one that fails on the data (a unique
constraint on duplicate rows…) only shows up in the real run, which then
rolls the conversions back.Only conversions to jsonb of properties the schema declares json can be
passed in migrations. The synchronization that follows brings every column
back to its declared type: any other conversion would be undone at once,
after rewriting the data twice. Declare the property json first. Such a
migration, or an invalid one (unknown op, cast or to), is refused
before anything runs.PostgreSQL only: on MongoDB, the result is empty.Read Operations
findOne: Find a single document
findOne: Find a single document
findMany: Find multiple documents
findMany: Find multiple documents
findAndCount: Find with total count
findAndCount: Find with total count
[entities, totalCount], useful for paginated UIs.count: Count documents
count: Count documents
distinct: Get distinct values
distinct: Get distinct values
aggregate: Aggregation pipeline
aggregate: Aggregation pipeline
Write Operations
create: Insert a single document
create: Insert a single document
createdAt and updatedAt are set automatically.bulkCreate: Insert multiple documents
bulkCreate: Insert multiple documents
Update Operations
updateOne: Update a single document
updateOne: Update a single document
updatedAt is set automatically. Returns { modifiedCount, matchedCount }.updateMany: Update multiple documents
updateMany: Update multiple documents
updateOne, but affects all matching documents.upsert: Insert or update
upsert: Insert or update
createdAt is set only on insert; updatedAt is always set.Delete Operations
deleteOne: Delete a single document
deleteOne: Delete a single document
{ deletedCount }.deleteMany: Delete multiple documents
deleteMany: Delete multiple documents
deleteOne, but deletes all matching documents.