Snippets Collections
db.getCollection('Transaction').aggregate([
    {"$group" : { "_id": "$transactionNo", "count": { "$sum": 1 }, "ids":{"$push":"$_id"} } },
    {"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } }
])
db.getCollection('AccountSummary').createIndex({txDate: NumberInt(1)});
db.getCollection('AccountSummary').createIndex({jobId:NumberInt(1)});
db.getCollection('AccountSummary').createIndex({userId:NumberInt(1)});
db.getCollection('AccountSummary').createIndex({isActive:NumberInt(1)});
db.Foo.aggregate(
  {$unwind: "$bars"},
  {$lookup: {
    from:"bar",
    localField: "bars",
    foreignField: "_id",
    as: "bar"

   }},
   {$match: {
    "bar.testprop": true
   }}
)
bookmark
dashboard

Mon Nov 02 2020 13:14:31 GMT+0000 (UTC) https://stackoverflow.com/questions/26984799/find-duplicate-records-in-mongodb

#mongoshell
bookmark
dashboard

Wed Aug 19 2020 06:27:09 GMT+0000 (UTC) https://docs.mongodb.com/manual/tutorial/manage-indexes/

#mongoshell
bookmark
dashboard

Thu May 21 2020 18:26:52 GMT+0000 (UTC) https://stackoverflow.com/questions/9621928/how-do-i-query-referenced-objects-in-mongodb

#javascript #mongoshell

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension