【发布时间】:2019-12-27 17:53:47
【问题描述】:
无法使用 mongodb+srv 协议连接到 Mongo DB Atlas。 在尝试查询一些数据时- MongoError:无法在 atlas 中对 admin 进行原始查询
我在 datasource.json 中尝试过的连接属性
mongoDb: {
connector: 'mongodb',
name: 'mongoDb',
url:"mongodb+srv://#username:#password@cluster0-kvw6a.mongodb.net/test?retryWrites=true&w=majority"
}
在尝试查询某些数据时 - 收到此错误
Unhandled error for request GET /api/Customers/getProfile?access_token=cMGG6C8fB8el0vbchpAzeOoTpH0N7Kf9va4b5k9Z6GrNAwgh4AtqQKlRYOyiWtsB: MongoError: cannot do
raw queries on admin in atlas
at Function.MongoError.create (C:\Users\User\Documents\GitHub\maharah\customer_server\node_modules\mongodb-core\lib\error.js:31:11)
at queryCallback (C:\Users\User\Documents\GitHub\maharah\customer_server\node_modules\mongodb-core\lib\cursor.js:212:36)
at C:\Users\User\Documents\GitHub\maharah\customer_server\node_modules\mongodb-core\lib\connection\pool.js:469:18
at process._tickCallback (internal/process/next_tick.js:61:11)
我在 datasource.json 中尝试过的连接属性
mongoDb: {
connector: 'mongodb',
name: 'mongoDb',
url:"mongodb+srv://#username:#password@cluster0-kvw6a.mongodb.net/test?
retryWrites=true&w=majority"
}
【问题讨论】:
-
请花一些时间来正确格式化您的代码
标签: node.js mongodb loopbackjs mongodb-atlas