如果(!db)抛出新错误('缺少db参数\ nnew Grid(db,mongo)'); ^错误:缺少db参数new Grid(db,mongo)

时间:2018-09-11 20:57:46

标签: mongodb mongoose gridfs

我想使用猫鼬连接到mongodb数据库,URL为http://localhost:27017/files,但出现错误提示

missing db argument
new Grid(db, mongo)

给出代码可能是什么问题

let express = require('express'); 
let app = express(); 
let bodyParser = require('body-parser');
let mongoose = require('mongoose');
mongoose.connect("http://localhost:27017/files",{useNewUrlParser:true});
let conn=mongoose.connection;
let multer=require('multer');
let GridfsStorage=require("multer-gridfs-storage");
let Grid=require("gridfs-stream");
Grid.mongo=mongoose.mongo;
let gfs=new Grid(conn.db);

stackoverflow中已经存在相同的问题,但是该解决方案对我不起作用,我已经在互联网上进行了大量搜索,但是...
任何帮助将不胜感激。

0 个答案:

没有答案