这个问题?"/>
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('运行操作前必须连接客户端');如何处理这个问题?
发布评论