CRUD Operations
CRUD operations create, read, update and delete documents. The operations are all atomic and provide strong data consistency guarantees.
Create operations
There are two flavors of create operations - insert, and replace.
Insert
Insert operations add new documents to a collection. Insert operations honor the primary key constraint and throw a duplicate key error if a document with the same primary key already exists.
Tigris TypeScript SDK provides the following two APIs to insert documents into a collection:
- insertOne(): insert single document
- insertMany(): batch insert documents
See the language-specific sections for more examples of Insert operations:
Replace
Replace operations provide the following behavior:
- replace a document with matching primary key value
- insert a new document if no document with matching primary key value found
Tigris TypeScript SDK provides the following two APIs to replace documents in a collection:
- insertOrReplaceOne(): replace single document
- insertOrReplaceMany(): batch replace documents
See the language-specific sections for more examples of Replace operations:
Read Operations
Read operations retrieve documents from a collection. Tigris by default indexes all the fields of the document allowing you to retrieve documents matching zero or more conditions on any field.
Tigris TypeScript SDK provides the following two APIs to read documents from a collection:
- findOne(): read a single document
- findMany(): read multiple documents
See the Filters section to learn more about the filters supported in read operations.
See the language-specific sections for more examples of Read operations:
Update Operations
Update operations modify existing documents in a collection. These operations give you the flexibility to update documents matching conditions on any field.
Tigris TypeScript SDK provides the following API to update documents in a collection:
- updateOne(): update one document that match the filtering condition
- updateMany(): update one or more documents that match the filtering condition
See the Filters section to learn more about the filters supported in update operations.
See the language-specific sections for more examples of Update operations:
Delete Operations
Delete operations remove documents from a collection. These operations give you the flexibility to delete documents matching conditions on any field.
Tigris TypeScript SDK provides the following API to delete documents from a collection:
See the Filters section to learn more about the filters supported in delete operations.
See the language-specific sections for more examples of Delete operations: