未定义ObjectID.在Mongo Shell中无法通过ID查找对象 [英] ObjectID is not defined. Cannot find object by id in Mongo Shell

查看:126
本文介绍了未定义ObjectID.在Mongo Shell中无法通过ID查找对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试用谷歌搜索我的简单问题,但找不到答案. 我找不到它的ObjectId.

I tried to google my simple problem, but cannot find answer. I can't find any object by it's ObjectId.

db.user.find({_id:ObjectID("57fa0a15cf1e8c0e571e1a52")})

ReferenceError:未定义ObjectID

ReferenceError: ObjectID is not defined

为什么?怎么了?

推荐答案

应为ObjectId()而不是ObjectID() https://docs.mongodb.com/manual/reference/method/ObjectId/

It should be ObjectId() not ObjectID() https://docs.mongodb.com/manual/reference/method/ObjectId/

这篇关于未定义ObjectID.在Mongo Shell中无法通过ID查找对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆