TypeError: grid.mongo.GridStore is not a constructor
i had this problem. The reason is that .GridStore is deprecated after the mongoose 6.0.5 version.
For solved i to this.
Create a second variable with the name
conection.once('open', () => {
//Init Stream
gridfsBucket = new mongoose.mongo.GridFSBucket(conection.db, {
bucketName: 'uploads'
})
gfs = Grid(conection.db, mongoose.mongo);
gfs.collection('uploads');
})
And for get the file I use that variable of this form.
const readStream = gridfsBucket.openDownloadStream(file._id);
readStream.pipe(res)