List of Common Queries - SCCapstone/EZBag GitHub Wiki

  • Create
db.product.insertMany([
{ _id: "9d8f57s56776d7", barcode: โ€œ1295783859843โ€, barcodeType: โ€œean13โ€, name: โ€œapplesโ€, price: 1.99, description: โ€œproduceโ€, businessID: 1, time:  19748736847 },
{ _id: "97f57s8646s45a", barcode: โ€œ3948689743743โ€, barcodeType: โ€œean13โ€, name: โ€œsteakโ€, price: 10.99, description: โ€œmeatโ€, businessID: 2, time: 349879728743 },
{ _id: "3jh5k24546k6n3", barcode: โ€œ2947849385445โ€, barcodeType: โ€œean13โ€, name: โ€œoreosโ€, price: 3.99, description: โ€œcookiesโ€, businessID: 2, time: 478373846384 }
]);
db.product.insertOne(
{ _id: "3jh5k24546k6n3", barcode: โ€œ2947849385445โ€, barcodeType: โ€œean13โ€, name: โ€œoreosโ€, price: 3.99, description: โ€œcookiesโ€, businessID: 2, time: 478373846384 }
);
  • Read
db.cart.find(
{ _id: โ€œ9d8f57s56776d7โ€ },
{ time: โ€œ129472478โ€, total: 10.54 }
); 
  • Update
db.info.updateOne(
{ _id: โ€œ9d8f57s56776d7โ€ },
{ $set: { phone: โ€œ7845291093โ€} }
);
  • Delete
db.info.deleteMany([
{ _id: โ€œ9d8f57s56776d7โ€, email: โ€œ[email protected]โ€, phone: 8513271443, time: 028492839 },
{ _id: โ€œ97f57s8646s45aโ€, email: โ€œ[email protected]โ€, phone: 8724351234, time: 129472478 },
{ _id: โ€œ3jh5k24546k6n3โ€, email: โ€œ[email protected]โ€ , phone: 3057618882, time: 376857393 }
]);
db.info.deleteOne([
{ _id: โ€œ9d8f57s56776d7โ€, email: โ€œ[email protected]โ€, phone: 8513271443, time: 028492839 }
]);
  • Search
db.product.find(
{ barcode: โ€œ1295783859843โ€ }
);
db.product.find(
{ name: /.*"apple".*/ }
);

Create and Update will need to join tables.