Skip to main content
This guide covers all CRUD (Create, Read, Update, Delete) operations in jasonisnthappy, including single and bulk operations.

Creating documents

Insert a single document

Insert a document into a collection. If no _id is provided, one will be auto-generated.
Rust
Go
Python
If your document includes an _id field and that ID already exists, the insert will fail. Use upsert to insert or update.

Insert multiple documents

Insert many documents in a single transaction for better performance.
Bulk inserts can achieve ~19,000 documents/second throughput. For best performance, use batches of 100-1000 documents per transaction.

Typed document insertion

Use Rust’s type system for compile-time safety:

Reading documents

Find by ID

Retrieve a single document by its unique identifier.

Find all documents

Retrieve every document in a collection.

Find with query

Filter documents using jasonisnthappy’s query language.
See the Querying guide for the full query syntax.

Find one document

Get the first document matching a query.

Count documents

Updating documents

Update by ID

Update fields on a specific document. Existing fields are merged.
The _id field cannot be changed. Updates preserve the original _id.

Update with query

Update all documents matching a query.

Update one document

Update only the first match.

Upsert operations

Insert a document if it doesn’t exist, otherwise update it.

Deleting documents

Delete by ID

Remove a specific document.

Delete with query

Remove all documents matching a query.

Delete one document

Remove only the first match.

Bulk operations

Perform multiple mixed operations in a single transaction.

Distinct values

Get unique values for a field across all documents.

Performance tips

For high-throughput writes:
  • Use insert_many instead of multiple insert calls
  • Batch 100-1000 documents per transaction
  • Consider bulk_write with ordered(false) for parallel execution
For reads:
  • Use typed methods (find_by_id_typed) to avoid JSON parsing overhead
  • Create indexes on frequently queried fields (see Indexes guide)
  • Use find_one instead of find when you only need the first result

Next steps

Querying

Learn the query language syntax

Indexes

Speed up queries with indexes

Schema validation

Enforce document structure

Aggregation

Analyze data with pipelines