-
-
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
[MONGODB DRIVER] DeprecationWarning: collection.findOneAndUpdate option [returnOriginal] is deprecated and will be removed in a later version #10285
Comments
i have the same prob |
Happening to me too. It must be from this latest version of mongoose (5.12.11) because I updated this today. I never placed option [returnOriginal] though. |
Happening to me on mongoose (5.12.10) aswell |
I'm gonna need a repro script from somebody because I can't reproduce it but enough of you are reporting this issue to cause concern. |
Hi just got it as well, narrowed it down to Model.findByIdAndUpdate. not sure if it's typescript only index.ts import mongoose, { Schema } from 'mongoose'
import { MongoMemoryServer } from 'mongodb-memory-server'
const deprecateMe = new Schema({
hello: Schema.Types.String,
})
const DeprecateMe = mongoose.model('yolo', deprecateMe)
const run = async () => {
const mms = new MongoMemoryServer()
const uri = await mms.getUri()
await mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
})
await DeprecateMe.findByIdAndUpdate(
'000000000000000000000004',
{
hello: '',
},
{
new: true,
}
)
}
run().then() my package.json "mongoose": "^5.12.11",
"mongodb-memory-server": "^6.9.6",
"ts-node": "^10.0.0",
"typescript": "^4.2.4" Console
Hope this helps, thanks for the awesome work :) lemme know if need more help note |
The deprecation was introduced in the latest MongoDB driver: "Currently, the driver supports the option returnOriginal for findOneAndUpdate, instead of the returnDocument option outlined in the CRUD spec. We should add support for returnDocument, and deprecate the returnOriginal flag." |
Ok so a couple things,
|
fixed deprecation warning for collection.findOneAndUpdate
Can you teach us how to fix it in the node_modules while we wait for the updates? |
I am getting this all of a sudden even though I've never used the "new" option or "returnOriginal". I use findOneAndUpdate in a number of places without problem. The single instance that is triggering this warning is this...
It also happens if I remove the third parameter entirely. FYI I have {useFindAndModify: false} set in my connection string. I tried reverting to 5.12.10 and the problem disappeared. |
@Roger-Heathcote please make sure you've upgraded to the latest version of Mongoose (v5.12.13 as of this writing). If you're still experiencing this issue, please open a new issue and follow the issue template. |
No description provided.
The text was updated successfully, but these errors were encountered: