-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs page for how to fix deprecation warnings #6922
Comments
If these are set, would it be incompatible with or breaking the current program? |
@islishude the only differences we are aware of are:
If you run into any other problems, please don't hesitate to open up a GitHub issue. |
I set I've tried it before and after |
@ulrichb Are you sure that you're using [email protected] that released an hour ago? |
I can replicate what @ulrichb is seeing on 5.2.10 with: 6922.js#!/usr/bin/env node
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true });
mongoose.set('useCreateIndexes', true);
const conn = mongoose.connection;
const Schema = mongoose.Schema;
const schema = new Schema({
name: {
type: String,
unique: true
}
});
const Test = mongoose.model('test', schema);
const test = new Test({ name: 'one' });
async function run() {
console.log(`mongoose version: ${mongoose.version}`);
await conn.dropDatabase();
await test.save();
return conn.close();
}
run(); Output:
|
I believe it is |
updated the original comment to reflect @saagar2000's observation. Thanks @saagar2000 ! |
@vkarpov15 is it possible to rename the document method Currently I'm refactoring all Model based usage of E.g.
|
I'm seeing the
|
@adamreisnz yeah we should add an alias |
mongoose.set('useCreateIndex', true) has no affect for me. 😞 |
@ParikshitChavan Did you set this option before calling |
Using mongoose 5.2.12. I also get this: More info: I only get this extra message when pass |
looks like it should work properly when pass as connection option, but it doesn't. only after explicit |
@Fonger @govindrai |
Same here, cant get rid of |
@ParikshitChavan @govindrai @Avcajaraville You have to put See the discussion in #6890. This is fixed in 5.2.13 (but it's not released yet). |
@Fonger @vkarpov15 after upgrade to 5.2.13 the issue still exists
package.json:
node and npm info:
|
@arastu can you create a reproducible example with one or more files where you demonstrate that you are using 5.2.13 and are seeing one or more of these warnings? Note that I am calling For Example: index.js#!/usr/bin/env node
'use strict';
const assert = require('assert');
const mongoose = require('mongoose');
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true });
const conn = mongoose.connection;
const One = require('./one');
const Two = require('./two');
const one = new One({ name: '1' });
const two = new Two({ name: '2' });
async function run() {
assert.strictEqual(mongoose.version, '5.2.13');
await conn.dropDatabase();
await Promise.all([One.init(), Two.init()]);
await one.save();
await two.save();
await One.findOneAndUpdate({}, { name: 'one' });
await Two.findOneAndUpdate({}, { name: 'two' });
console.log(`${mongoose.version} should show no deprecations with the new settings.`);
return conn.close();
}
run(); one.js'use strict';
const mongoose = require('mongoose');
const schema = new mongoose.Schema({ name: { type: String, unique: true } });
module.exports = mongoose.model('one', schema); two.js'use strict';
const mongoose = require('mongoose');
const schema = new mongoose.Schema({ name: { type: String, unique: true } });
module.exports = mongoose.model('two', schema); Output:
|
I've upgraded to |
@mycompassspins Did you track the stack producing the warning ? For instance, in my case turns out the deprecation warning was happening due to connect mongo. If you follow the above instructions, at least for me, all deprecation warning where gone :) |
Here's the stack:
Obviously,
|
@mycompassspins are you sure you're on 5.2.14? We added |
Alternative patch implementation using Mongoose `findByIdAndUpdate`: https://mongoosejs.com/docs/api.html#model_Model.findByIdAndUpdate Notice: The `new` determines whether to return the new (i.e., updated) version (default: false) Caveats: Mongoose is in the process of changing their API: Automattic/mongoose#6922 (comment) To fix the deprecation warnings, we need to set: ```js mongoose.set('useFindAndModify', false); ```
Alternative patch implementation using Mongoose `findByIdAndUpdate`: https://mongoosejs.com/docs/api.html#model_Model.findByIdAndUpdate Notice: The `new` determines whether to return the new (i.e., updated) version (default: false) Caveats: Mongoose is in the process of changing their API: Automattic/mongoose#6922 (comment) To fix the deprecation warnings, we need to set: ```js mongoose.set('useFindAndModify', false); ```
There's an internal configuration typo in |
(node:6455) DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead. What about this ??. |
@venkyyPoojari that's an old one, predates mongoose 5, but worth addressing. We will fix. |
Thanks, I am going to use this for production, so please help as soon as possible |
I have the same issue, I'm piping the readstream to the res object, is this what is wrong? I mean does it prevent the files to be read out? |
@venkyyPoojari @romain10009 that's because gridfs-stream is out of date. The MongoDB driver has a new streaming API for GridFS that you should use instead: https://thecodebarbarian.com/mongodb-gridfs-stream |
After #6917 it should now be possible to clear up all deprecation warnings by:
update()
withupdateOne()
,updateMany()
, orreplaceOne()
remove()
withdeleteOne()
ordeleteMany()
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.set('useNewUrlParser', true);
Need a docs page to summarize this.
The text was updated successfully, but these errors were encountered: