Можем ли мы использовать условие Nested where в коллекции sails js - PullRequest
0 голосов
/ 05 мая 2018

Я пытаюсь выполнить запросы ниже, чтобы получить выходные данные, у которых start_date больше текущей даты.

Это в структуре моей коллекции:

{ 
    "_id" : ObjectId("5aeac6cd1b7e6f252832ca0e"), 
    "recruiter_id" : null, 
    "university_id" : null, 
    "type" : "quiz", 
    "name" : "Enter scheduled quiz without end date", 
    "description" : "Even after detailed market research, some products just don't work in the market. Here's a case study from the Coca-Cola range. ", 
    "quizpoll_image" : "story_7.jpeg", 
    "status" : "1", 
    "quizpoll_type" : "scheduled", 
    "duration" : {
        "duration_type" : "Question wise", 
        "total_duration" : "1000"
    }, 
    "questions" : [
        {
            "question_id" : "5aeaa4021b7e6f00dc80c5c6"
        }, 
        {
            "question_id" : "5aeaa59d1b7e6f00dc80c5d2"
        }
    ], 
    "date_type" : {
        "start_date" : ISODate("2018-05-01T00:00:00.000+0000")
    }, 
    "created_at" : ISODate("2018-05-01T00:00:00.000+0000"), 
    "updated_at" : ISODate("2018-04-26T07:58:17.795+0000")
}

Это запрос, который я пытаюсь:

var isoCurrentDate = current_date.toISOString();
        var quizScheduledData = await QuizListingCollection.find({
                where: ({
                    'type':'quiz',
                    'status':'1',
                    'quizpoll_type':'scheduled',
                    'date_type' :{
                            'start_date':{
                                '>': isoCurrentDate       
                            }
                        }
                    })
            });

Это ошибка, которую я получаю при попадании этого API в почтальон

{
    "cause": {
        "name": "UsageError",
        "code": "E_INVALID_CRITERIA",
        "details": "Could not use the provided `where` clause.  Could not filter by `date_type`: Unrecognized modifier (`start_date`) within provided constraint for `date_type`."
    },
    "isOperational": true,
    "code": "E_INVALID_CRITERIA",
    "details": "Could not use the provided `where` clause.  Could not filter by `date_type`: Unrecognized modifier (`start_date`) within provided constraint for `date_type`."
}

1 Ответ

0 голосов
/ 05 мая 2018
{
where: {
        'type':'quiz',
        'status':'1',
        'quizpoll_type':'scheduled',
        'date_type.start_date': {
                '>' : isoCurrentDate 
    }
  }
}
...