Skip to content

Instantly share code, notes, and snippets.

@m-sedl
Created December 9, 2022 15:50
Show Gist options
  • Save m-sedl/3c3daaa971861c74d20f20bb3487ff90 to your computer and use it in GitHub Desktop.
Save m-sedl/3c3daaa971861c74d20f20bb3487ff90 to your computer and use it in GitHub Desktop.
db.createCollection("products");
db.createCollection("orders");
db.products.insertMany([
{ name: "milk", price: 45.50 },
{ name: "bread", price: 30.99 },
{ name: "cheese", price: 123.59 },
{ name: "sugar", price: 53.59 },
]);
db.products.find();
db.orders.insertMany([
{ customer: "Ivan", created_at: 1670600517, items: [
{id: ObjectId("639356156425783af7d5f1b0"), count: 3},
{id: ObjectId("639356156425783af7d5f1ae"), count: 1},
] },
{ customer: "Petr", created_at: 1639064517, items: [
{id: ObjectId("639356156425783af7d5f1b0"), count: 1},
{id: ObjectId("639356156425783af7d5f1b1"), count: 5},
{id: ObjectId("639356156425783af7d5f1ae"), count: 4},
] },
{ customer: "Jessica", created_at: 1646840517, items: [
{id: ObjectId("639356156425783af7d5f1b0"), count: 1},
{id: ObjectId("639356156425783af7d5f1b1"), count: 5},
{id: ObjectId("639356156425783af7d5f1ae"), count: 4},
] },
]);
db.orders.find();
db.orders.find({created_at: {"$gt": 1643673600}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment