i use gridfs to store the files in monogodb when i retrive files to database i make the Grid type object but here the error which is missing db argument how to solve this
import mongoose from "mongoose";
import Folders from "../models/Folder.js";
import path from "path";
import Grid from "gridfs-stream";
import fs from "fs";
const connection = mongoose.connection;
// Grid.mongo = mongoose.mongo;
// const gfs = Grid(mongoose.connection.db, mongoose.mongo);
// Grid.mongo = mongoose.mongo;
const db = mongoose.connection.db;
const mongo = mongoose.mongo;
var gfs = Grid(db,mongo);
here the output:

From the
Connection.prototype.dbdocumentation:This means the
mongoose.connection.dbwill be set when the connection is opened. Before the connection is opened, the value isundefined. That's why you got the error,gridfs-streamlibrary will validate the parameters here 1.1.1/lib/index.js#L25Connect the database server first using
mongoose.connect()method.Logs:
package versions: