【问题标题】:findOne document without a particular element [duplicate]findOne 没有特定元素的文档[重复]
【发布时间】:2020-08-05 23:27:18
【问题描述】:

我有这个架构:

text = {
    name : String,
    text: String,
    class: String (optional)
}

我怎样才能找到一个还没有上课的人?

我希望是这样的:

text.findOne({
    class: null
})
.then(text => res.json(text))

【问题讨论】:

标签: reactjs mongodb mongoose


【解决方案1】:

你可以试试这个:

text.findOne({
    "class" : { "$exists" : false } 
}).then(text => res.json(text))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    • 2016-07-30
    • 2013-04-30
    • 2019-03-15
    • 2020-08-20
    相关资源
    最近更新 更多