I have a collection called bills in a database.
Each document in the collection is a bill that was passed in congress.
Within each document, there is an array called votingRecord, comprised of objects that are the voting records of each congress member.
I need to be able to sort and find specific keys/values within the votingRecord array
, and I can't figure it out.
I tried examples listed here, but my issue is that each document in my collection has the nested array of objects made of the representatives ("votingRecord").
I need to set an initial filter in my query so that I can search the specific votingRecord for the specific bill.
{
"_id" : ObjectId("5dc209b7af26e560a3204bcc"),
"bill_id" : "hr676-116",
"title" : "To reiterate the support of the Congress of the United States for the North Atlantic Treaty Organization, and for other purposes.",
"sponsorState" : "CA",
"sponsorParty" : "D",
"summary" : "NATO Support Act This bill prohibits the appropriation or use of funds to withdraw the United States from the North Atlantic Treaty Organization.",
"primarySubject" : "NATO Support Act This bill prohibits the appropriation or use of funds to withdraw the United States from the North Atlantic Treaty Organization.",
"introducedDate" : "2019-01-17",
"latestMAction" : "Received in the Senate.",
"votingRecord" : [
{
"person" : 400440,
"state" : "AK",
"district" : 0,
"vote" : "Yea",
"name" : "Rep. Don Young [R]",
"party" : "Republican"
},
//( five hundred or so of these objects(all reps + senators), ending with)
],
"latestMActionDate" : "2019-01-23",
"__v" : 0
}
my MongoDB shell isn't responding to any of the queries I've made.
db.bills.find({"introducedDate": 2019-01-03},{votingRecord: {$elemMatch: {state:"FL"}}})
the above query felt like the closest, because I specified by "introducedDate," but no luck so far.