Как я могу ввести конкретный запрос в mongoDB, - PullRequest
0 голосов
/ 09 ноября 2019

Я пытаюсь получить отчет о голосовании по конкретным законопроектам на конгрессе, это структура моей модели мангуста:

    "_id" : ObjectId("5dc496d1fee37b184efaaf73"),
    "bill_id" : "hr312-116",
    "title" : "To reaffirm the Mashpee Wampanoag Tribe reservation, and for other purposes.",
    "sponsorState" : "MA",
    "sponsorParty" : "D",
    "summary" : "Mashpee Wampanoag Tribe Reservation Reaffirmation Act This bill reaffirms the Mashpee Wampanoag Tribe reservation as trust land in Massachusetts. In addition, the bill requires actions, including actions pending in federal court, relating to the land to be dismissed.",
    "primarySubject" : "Mashpee Wampanoag Tribe Reservation Reaffirmation Act This bill reaffirms the Mashpee Wampanoag Tribe reservation as trust land in Massachusetts. In addition, the bill requires actions, including actions pending in federal court, relating to the land to be dismissed.",
    "introducedDate" : "2019-01-08",
    "latestMAction" : "Read the second time. Placed on Senate Legislative Calendar under General Orders. Calendar No. 92.",
    "votingRecord" : [ 
        {
            "person" : 400440,
            "state" : "AK",
            "district" : 0,
            "vote" : "No",
            "name" : "Rep. Don Young [R]",
            "party" : "Republican"
        }, .... ]

Это то, что я пытаюсь, и ответ не определен:

findAllVotes: function(req, res) {

        db
            .find(req.query)
            .sort({ state: 0 })
            .select("votingRecord")
            .then(dbModel => res.json(dbModel))
            .catch(err => res.status(422).json(err));
    }

1 Ответ

0 голосов
/ 09 ноября 2019

проверьте ваше состояние в сортировке function.in коллекции вашего поля состояния: 'AK' и в сортировке вы предоставляете состояние: 0

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...