我正在尝试使用以下代码在新集合中插入更多文档:
await client.db(db).collection(newCollection).insertOne(newDocument);
但是,这会遇到错误代码8000,这里没有记录:https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml .
MongoServerError: cannot create a new collection -- already using 500 collections of 500
at Connection.onMessage (/home/pi/projects/myProject/node_modules/mongodb/lib/cmap/connection.js:210:30)
at MessageStream.<anonymous> (/home/pi/projects/myProject/node_modules/mongodb/lib/cmap/connection.js:63:60)
at MessageStream.emit (node:events:527:28)
at processIncomingData (/home/pi/projects/myProject/node_modules/mongodb/lib/cmap/message_stream.js:132:20)
at MessageStream._write (/home/pi/projects/myProject/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:390:12)
at _write (node:internal/streams/writable:331:10)
at Writable.write (node:internal/streams/writable:335:10)
at TLSSocket.ondata (node:internal/streams/readable:766:22)
at TLSSocket.emit (node:events:527:28) {
ok: 0,
code: 8000,
codeName: 'AtlasError',
[Symbol(errorLabels)]: Set(0) {}
}
我做了进一步的研究,发现一个创建的集合的数量不受用户的限制("一般来说,尽量将您的副本集限制为10,000个集合"),如下所示:https://www.mongodb.com/developer/products/mongodb/schema-design-anti-pattern-massive-number-collections/#:~:text=In%20general%2C%20try%20to%20limit%20your%20replica%20set%20to%2010%2C000%20collections.
我在一个共享集群上使用Atlas。这是Atlas的问题还是我的代码的问题?
是的,这是atlas M0免费限制。见Database and Collections