Last active
December 20, 2015 04:09
-
-
Save CraftyFella/6069007 to your computer and use it in GitHub Desktop.
Mongovue Query Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Querying arrays by their size | |
{ | |
"Field1": {$size: 0} | |
"Field2": {$not: {$size: 0}} | |
} | |
// Querying nested fields using a unique identifier | |
{ | |
"Events.Payload.Body._t" : "EventType", | |
"Events.Payload.Body._id" : CSUUID("2267495d-63e3-4aa3-ae67-86372a7968fd") | |
} | |
// Aggregate with lots of examples of different queries.. | |
{ $match : { "Risk.contactDetails.outBoundingOptIn" : "True" } }, | |
{ $match : { "CommencedAt" : { $gte : ISODate("2014-01-14T00:00:00.000Z"), | |
$lt: ISODate("2014-01-15T00:00:00.000Z") } }}, | |
{ $unwind : "$Quotes" }, | |
{ $match : { "Quotes.Brand" : { $in :["AHH3", "HLF3", "SNN3"] } } }, | |
{ $match : { "Quotes.Position" : { $in :[1, 2] } } }, | |
{ $group : { _id : "$Quotes.Brand", | |
count : { $sum : 1 }}}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment