1

i want to connect to mongodb database using mongoose, the url is http://localhost:27017/files but i get the error which says

missing db argument
new Grid(db, mongo)

what can be the problem given the code:

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);

the same question is already there in stackoverflow but the solution does not work for me and i have searched a lot on the internet but...
any help will be highly appreciated.

jalil
  • 476
  • 1
  • 7
  • 16
  • Theres an answer to this [here](https://stackoverflow.com/questions/46705438/gridfs-and-mongoose-file-upload/56509278#56509278) and another one [here](https://stackoverflow.com/questions/49428674/passing-mongoose-as-an-argument-to-a-function) –  Jun 08 '19 at 19:16

0 Answers0