admin 管理员组文章数量: 1184232
MongoNotConnectedError('运行操作前必须连接客户端');如何处理这个问题?
每次运行代码时都会收到以下错误消息:
G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\operations\execute_operation.js:23
throw new error_1.MongoNotConnectedError('Client must be connected before running operations');
^
MongoNotConnectedError: Client must be connected before running operations
at executeOperationAsync (G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\operations\execute_operation.js:23:19)
at G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\operations\execute_operation.js:12:45
at maybeCallback (G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\utils.js:278:21)
at executeOperation (G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\operations\execute_operation.js:12:38)
at Collection.insertOne (G:\Web Development\Projects\simple-crud-server\node_modules\mongodb\lib\collection.js:145:57)
at G:\Web Development\Projects\simple-crud-server\index.js:38:43
at Layer.handle [as handle_request] (G:\Web Development\Projects\simple-crud-server\node_modules\express\lib\router\layer.js:95:5)
at next (G:\Web Development\Projects\simple-crud-server\node_modules\express\lib\router\route.js:144:13)
at Route.dispatch (G:\Web Development\Projects\simple-crud-server\node_modules\express\lib\router\route.js:114:3)
at Layer.handle [as handle_request] (G:\Web Development\Projects\simple-crud-server\node_modules\express\lib\router\layer.js:95:5) {
[Symbol(errorLabels)]: Set(0) {}
}
[nodemon] app crashed - waiting for file changes before starting...
我正在尝试从客户端在数据库中设置数据。但是每次我得到上面的错误。 作为参考(如果有帮助),这是我创建并运行的种子文件:
我该如何解决这个错误?
回答如下:本文标签: MongoNotConnectedError(39运行操作前必须连接客户端39)如何处理这个问题
版权声明:本文标题:MongoNotConnectedError('运行操作前必须连接客户端');如何处理这个问题? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.roclinux.cn/b/1717571593a708960.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论