Skip to content

Instantly share code, notes, and snippets.

@ran488
Created October 28, 2015 23:22
Show Gist options
  • Save ran488/f2a2e4841b888c51f1f5 to your computer and use it in GitHub Desktop.
Save ran488/f2a2e4841b888c51f1f5 to your computer and use it in GitHub Desktop.
MongoDB Aggregation Framework - Various Example Queries
// http://docs.mongodb.org/manual/reference/operator/aggregation/
db.agencyProfiles.aggregate( [
{ $match: {"_id":"Florida SUI Wage"} },
{ $unwind: "$agencyErrors" },
{ $project: {_id:0, agencyErrors: {errorDescription:1, cannedAction:{actionCodeDescription:1}}}}
] )
db.outboundAcksInfo.aggregate( [
{ $match: {"uniqueFilingIdentifier":"Minnesota SUI Wage",
"outBoundFileName": "009300161ta7"
}
},
{ $unwind: "$ackIdLineInfo" },
{ $project: {"_id": 0, ackIdLineInfo: {ackId: 1, startLineNumber:1, } } }
] )
db.outboundAcksInfo.aggregate( [
{ $match: {"uniqueFilingIdentifier":"Minnesota SUI Wage",
"outBoundFileName": "009300161ta7"
}
},
{ $unwind: "$ackIdLineInfo" },
{ $match: {"ackIdLineInfo.startLineNumber":2970} },
{ $project: {"_id": 0, ackIdLineInfo: {ackId: 1, startLineNumber:1, } } }
] )
db.outboundAcksInfo.aggregate( [
{ $match: {"uniqueFilingIdentifier":"Minnesota SUI Wage",
"outBoundFileName": "009300161ta7"
}
},
{ $unwind: "$ackIdLineInfo" },
{ $match: { "ackIdLineInfo.startLineNumber": {$lte:3190},
"ackIdLineInfo.endLineNumber": {$gte:3190}
}
},
{ $project: {"_id": 0, ackIdLineInfo: {ackId: 1, startLineNumber:1, endLineNumber:1} } }
] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment