CRUD Operations on Documents
What you'll learn: How document stores expose simple, intuitive APIs for creating, reading, updating, and deleting individual documents.
The Core Idea
CRUD stands for Create, Read, Update, Delete — the four fundamental operations you perform on data. Document stores make these operations straightforward through simple APIs that work directly with JSON-like documents. Unlike SQL's complex query language, you interact with documents using method calls that feel natural in modern programming languages.
Think of it like managing files in a folder: you can create a new file, open and read one, edit its contents, or delete it entirely. Document stores provide similar operations, but for structured documents in a database.
The Four Operations
Create inserts a new document into a collection, often auto-generating a document ID if you don't provide one. You pass the document as a JSON object.
Read retrieves a document by its ID or by querying specific fields (using the indexing and querying capabilities you've learned). Reading a single document by ID is extremely fast — typically an O(1) operation.
Update modifies an existing document. You can replace the entire document, or update specific fields while leaving others unchanged. Some document stores support atomic field updates (increment a counter, append to an array).
Delete removes a document from the collection by its ID.
Why This Matters
These simple operations align naturally with object-oriented programming. Your application objects map directly to documents, and CRUD operations feel like native method calls rather than translating logic into SQL statements. This reduces impedance mismatch between your code and database.
The API simplicity doesn't sacrifice power — you still have indexes for fast queries and can embed or reference related documents as needed.
Key Takeaway: Document stores provide intuitive Create, Read, Update, and Delete APIs that work directly on JSON-like documents, making database operations feel like natural object manipulation in your application code.