【问题标题】:mongodb findOne not found document in basemongodb findOne 在基础中找不到文档
【发布时间】:2020-06-29 17:11:27
【问题描述】:

在我的收藏中,我有这个文件:

{
    "_id" : ObjectId("5eecb84a9e41ff609fd6389a"),
    "uid" : NumberLong(619942065802969109),
    "banmute" : 0,
    "expire" : ISODate("2023-03-15T13:06:18.694Z"),
    "fid" : "3cac4490b6ca491e838d4e5317e5b87e",
    "id" : null,
    "nick" : "Flawe",
    "nicks_ld" : "",
    "old_nicks" : "",
    "reason" : ""
}

索引是:

/* 1 */
[
    {
        "v" : 2,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "fsl.index_profile"
    },
    {
        "v" : 2,
        "unique" : true,
        "key" : {
            "uid" : 1
        },
        "name" : "uid_1",
        "ns" : "fsl.index_profile",
        "background" : true
    }
]

根据直接要求,我的答案为空:

db.getCollection('index_profile').findOne({uid: 619942065802969109})
result: ->
null

但如果我请求 $gte 我找到了它:

db.getCollection('index_profile').find({uid: {$gte: 619942065802969109}}).limit(1)
result: ->
/* 1 */
{
    "_id" : ObjectId("5eecb84a9e41ff609fd6389a"),
    "uid" : NumberLong(619942065802969109),
    "banmute" : 0,
    "expire" : ISODate("2023-03-15T13:06:18.694Z"),
    "fid" : "3cac4490b6ca491e838d4e5317e5b87e",
    "id" : null,
    "nick" : "Flawe",
    "nicks_ld" : "",
    "old_nicks" : "",
    "reason" : ""
}

我尝试删除缓存、重启服务器、删除索引、分配不同的新索引

我很绝望,帮忙解决这个问题

【问题讨论】:

    标签: mongodb mongodb-query


    【解决方案1】:

    你试过了吗:

    db.getCollection('index_profile').findOne({uid: NumberLong(619942065802969109)})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 2020-07-03
      • 2014-02-04
      相关资源
      最近更新 更多