尝试建立数据库连接时出错

时间:2019-03-06 11:01:18

标签: node.js mongodb mongoose

this is the piece of code that i have written for connection with db

cmd行运行时显示的错误 节点server.js cmd是

(node:23060) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Listening  on port 3000
C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\operations\mongo_client_ops.js:474
  throw err;
  ^

MongoError: database names cannot contain the character ' '
at Function.create (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb-core\lib\error.js:43:12)
at validateDatabaseName (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\operations\db_ops.js:728:24)
at new Db (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\db.js:181:3)
at MongoClient.db (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\mongo_client.js:268:14)
at C:\Users\HP\Documents\SE project\node_modules\mongoose\lib\connection.js:527:62
at result (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\utils.js:414:17)
at executeCallback (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\utils.js:406:9)
at err (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\operations\mongo_client_ops.js:294:5)
at connectCallback (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\operations\mongo_client_ops.js:249:5)
at process.nextTick (C:\Users\HP\Documents\SE project\node_modules\mongoose\node_modules\mongodb\lib\operations\mongo_client_ops.js:471:7)
at processTicksAndRejections (internal/process/next_tick.js:74:9)

0 个答案:

没有答案
相关问题