I have a problem when querying mongoDB with nested objects notation: db.messages.find( { headers : { From: "reservations@marriott.com" } } ).count() 0 db.messages.find( { 'headers.From': "reservations@marriott.com" } ).count() 5...
  • May 20, 2022
  • 0 Comments
I’d like to get the names of all the keys in a MongoDB collection. For example, from this: db.things.insert( { type : ['dog', 'cat'] } ); db.things.insert( { egg...
  • May 11, 2022
  • 0 Comments
I am looking to get a random record from a huge collection (100 million records). What is the fastest and most efficient way to do so? The data is...
  • May 8, 2022
  • 0 Comments
Suppose you have the following documents in my collection: { "_id":ObjectId("562e7c594c12942f08fe4192"), "shapes":[ { "shape":"square", "color":"blue" }, { "shape":"circle", "color":"red" } ] }, { "_id":ObjectId("562e7c594c12942f08fe4193"), "shapes":[ { "shape":"square", "color":"black" },...
  • May 5, 2022
  • 0 Comments
I’ve been playing around storing tweets inside mongodb, each object looks like this: { "_id" : ObjectId("4c02c58de500fe1be1000005"), "contributors" : null, "text" : "Hello world", "user" : { "following" :...
  • May 3, 2022
  • 0 Comments