MongoDB ObjectId() function not work and fix solution All In One

发布时间 2023-03-24 12:13:45作者: xgqfrms

MongoDB ObjectId() function not work and fix solution All In One

ObjectId() & UUID

https://www.mongodb.com/docs/manual/reference/method/ObjectId/

https://www.runoob.com/mongodb/mongodb-objectid.html

MongoDB`

$ brew tap mongodb/brew

# MongoDB Community Edition
$ brew install mongodb-community@4.2

# /usr/local/etc/mongod.conf
# /usr/local/var/log/mongodb
# /usr/local/var/mongodb

$ brew services list

# server
$ brew services start mongodb-community@4.2

$ brew services stop mongodb-community@4.2

$ mongod --config /usr/local/etc/mongod.conf --fork


$ ps aux | grep -v grep | grep mongod

# client
$ mongo

errors ❌

➜  ~ brew services list
Name                  Status   User       File
httpd                 error  9 xgqfrms-mm ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
mongodb-community@4.2 started  xgqfrms-mm ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community@4.2.plist
php                   none                
unbound               none                
➜  ~ ObjectId()
function> 
➜  ~ echo << ObjectId()
function heredoc> 

image

???

https://stackoverflow.com/questions/37182745/node-mongodb-objectid-not-working

findOne by ObjectId not working - Working with Data - MongoDB Developer Community Forums

https://www.mongodb.com/community/forums/t/findone-by-objectid-not-working/207456

solutions ✅

# chech
$ brew services list

# start mongodb server service
$ brew services start mongodb-community@4.2

$ mongo
MongoDB shell version v4.2.22
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("5168f398-9d51-494b-bdd2-2e78cbb88dff") }
MongoDB server version: 4.2.22
Server has startup warnings: 
2023-03-24T11:54:20.439+0800 I  CONTROL  [initandlisten] 
2023-03-24T11:54:20.439+0800 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2023-03-24T11:54:20.439+0800 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2023-03-24T11:54:20.439+0800 I  CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> ObjectId()
ObjectId("641d1f68ad7994a668cad1cb")
> quit();

image

(? 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://www.cnblogs.com/xgqfrms/p/9770091.html#5161122



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 ?️,侵权必究⚠️!