As commitment to our database literacy campaign, we're offering our Database Foundations course—for FREE!

Skip to main content
Completion requirements
  • Create:
    Insert new documents into a collection.

    db.users.insertOne({
        name: "Alice",
        age: 28,
        interests: ["reading", "hiking"],
        address: { city: "Denver", state: "CO" }
    });
    
  • Read:
    Retrieve documents using queries.

    // Find by a simple query
    db.users.find({ name: "Alice" }).toArray();
    
    // Find using projections to return specific fields
    db.users.find({ age: { $gt: 25 } }, { name: 1, interests: 1 }).toArray();
    
  • Update:
    Modify existing documents.

    db.users.updateOne(
        { name: "Alice" },
        { $set: { "address.city": "Boulder" } }
    );
    
  • Delete:
    Remove documents from a collection.

    db.users.deleteOne({ name: "Alice" });
Last modified: Saturday, 12 April 2025, 11:16 AM