question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DeprecationWarning: GridStore is deprecated

See original GitHub issue

mongodb version is 3.1.1

(node:65150) DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:13

github_iconTop GitHub Comments

8reactions
stevenlobocommented, Oct 22, 2018

The mongoose docs at https://mongoosejs.com/docs/deprecations.html#-gridstore- indicates the reason for the depreciation warning and path forward:

That is because gridfs-stream relies on a deprecated MongoDB driver class. 
You should instead use the MongoDB driver's own streaming API 

// Replace this:
const conn = mongoose.createConnection('mongodb://localhost:27017/gfstest');
const gfs = require('gridfs-store')(conn.db);
const writeStream = gfs.createWriteStream({ filename: 'test.dat' });

// With this:
const conn = mongoose.createConnection('mongodb://localhost:27017/gfstest');
const gridFSBucket = new mongoose.mongo.GridFSBucket(conn.db);
const writeStream = gridFSBucket.openUploadStream('test.dat');

There is also a link on that site that provides usage examples of GridFSBucket.

7reactions
Yaxiancommented, Apr 16, 2020
  import {GridFSBucket, MongoClient, ObjectId} from 'mongodb';
  import { Readable } from 'stream';

  let connection = MongoClient.connect(url, { 
       useNewUrlParser: true,
       useUnifiedTopology: true
   } );
  let db = connection.db(dbName);
  let gridfsBucket = new GridFSBucket(db, {bucketName: bucketName});
  let downloadStream = gridfsBucket.openDownloadStream(new ObjectId(_id));

  let buffer = [];
  downloadStream.on('data', (chunk) => {
       buffer.push(chunk);
  });
  downloadStream.on('end', () => {
       let readable = new Readable();
       readable._read = () => {};
       readable.push(Buffer.concat(buffer));
       readable.push(null);
  });

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to replace gridStore to gridFSBucket? - Stack Overflow
If you run into ( DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead ), hope ......
Read more >
Mongoose v5.13.15: Deprecation Warnings
DeprecationWarning : GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead. That is because gridfs-stream relies on...
Read more >
reactioncommerce/reaction - Gitter
(node:75) DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead api_1 | (node:75) ...
Read more >
gridfs-stream - Bountysource
Cursor.nextObject was deprecated since version 2 of the node-mongodb-native library and was now removed completely from the library. Because gridfs-stream uses ...
Read more >
Legacy GridStore - GitHub Pages
The GridStore API is deprecated. Driver version 2.0 and later uses the GridFS API. GridStore. GridStore is a single file inside GridFS that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found