Skip to content
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

Cannot read property '_update' of undefined #8160

Closed
AdamBCo opened this issue Sep 13, 2019 · 2 comments
Closed

Cannot read property '_update' of undefined #8160

AdamBCo opened this issue Sep 13, 2019 · 2 comments

Comments

@AdamBCo
Copy link

AdamBCo commented Sep 13, 2019

Do you want to request a feature or report a bug?
*bug

What is the current behavior?
When using findOneAndUpdate, I receive the following error: Cannot read property '_update' of undefined. The find and findOne queries work as expected.

Please find the model I am using, along with the query I am trying to perform below.

Model

const schema = mongoose.Schema(
	{
		name: { type: String, trim: true }
	}
	{
		timestamps: {
			createdAt: 'created_at',
			updatedAt: 'updated_at'
		}
	}
)

module.exports = mongoose.model('Contact', schema)

Query

Contact.findOneAndUpdate({
	_id
}, {
	$set: {
	    name: "adam"
    }
}, {
	new: true 
})
	.then((result) => res.status(200).json(result))
	.catch((error) => res.boom.badRequest(error))

What is the expected behavior?
I expect to recieve an updated Contact object.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 5.7.0

@fernandolguevara
Copy link
Contributor

@AdamBCo try with version 5.7.1 this bug is fixed with #8151

@vkarpov15
Copy link
Collaborator

This issue should be fixed in 5.7.1 as @fernandolguevara said. Sorry for the trouble!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants