我们可以在sails js Collection中使用Nested where子句吗?

时间:2018-05-05 02:57:46

标签: sails.js sails-mongo

我正在尝试查询以获取start_date大于当前日期的输出。

这些我的收藏结构:

time

这是我正在尝试的查询:

@foreach($cvs as $cv)
                    <div class="col-sm-6 col-md-4">
                    <div class="thumbnail">
                        <img src="{{ asset('storage/'.$cv->photo) }}" alt="...">
                        <div class="caption">
                        <h3>{{ $cv->titre }}</h3>
                        <p>{{$cv->presentation}}</p>
                        <p>
                            <a href="#" class="btn btn-primary" role="button">Afficher</a>
                            <a href="#" class="btn btn-success" role="button">Modifier</a>
                            <a href="#" class="btn btn-danger" role="button">Supprimer</a>
                         </p>
                        </div>
                    </div>
                    </div>
                    @endforeach
                    </div>
               </div>

这是我在postman中点击这个api时得到的错误

{ 
    "_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")
}

1 个答案:

答案 0 :(得分:0)

{
where: {
        'type':'quiz',
        'status':'1',
        'quizpoll_type':'scheduled',
        'date_type.start_date': {
                '>' : isoCurrentDate 
    }
  }
}