Documents

A document is a single unit of data inside a collection — like a row in SQL or an object in a JSON array.

In NotDatabase, documents are just structured key-value objects that follow your collection's schema.

✍️ Inserting Documents

Use the .insert() method to add a new document to a collection:

await db.users.insert({
  name: "Jian-Yang",
  email: "jianyang@piedpiper.com",
});

📄 What a Document Looks Like

Every document automatically includes:

  • _id: A unique identifier (you can override with key)
  • createdAt: Timestamp of when the doc was created
  • updatedAt: Timestamp of last update

Example:

{
  "_id": "abc123",
  "name": "Jian-Yang",
  "email": "jianyang@piedpiper.com",
  "createdAt": "2025-06-19T12:00:00Z",
  "updatedAt": "2025-06-19T12:00:00Z"
}