You can use $inc
for this purpose.
Try this:
var id = req.body.id;
Meme.findOneAndUpdate({_id :id}, {$inc : {'post.likes' : 1}}).exec(...);
For more info on $inc, Please read MongoDB $inc documentation
More Related Contents:
- Push items into mongo array via mongoose
- E11000 duplicate key error index in mongodb mongoose
- Mongoose: findOneAndUpdate doesn’t return updated document
- Mongoose populate vs object nesting
- Stop Mongoose from creating _id property for sub-document array items
- Populate nested array in mongoose
- Why does mongoose always add an s to the end of my collection name
- Cannot overwrite model once compiled Mongoose
- Mongoose Schema hasn’t been registered for model
- Mongoose findByIdAndUpdate not returning correct model
- Mongoose duplicate key error with upsert
- Mongoose (mongodb) batch insert?
- How can I use a cursor.forEach() in MongoDB using Node.js?
- Mongoose update without callback
- Model.find().toArray() claiming to not have .toArray() method
- Mongoose optional search query parameters?
- Difference between MongoDB and Mongoose
- How can I save multiple documents concurrently in Mongoose/Node.js?
- Mongoose: CastError: Cast to ObjectId failed for value “[object Object]” at path “_id”
- Model.find() returns empty in mongoose [duplicate]
- log all queries that mongoose fire in the application
- Combine two OR-queries with AND in Mongoose
- Mongoose – finding subdocuments by criteria
- Mongoose findOneAndUpdate and runValidators not working
- Mongoose: ObjectId Comparisons fail inconsistently
- Mongoose multiple connections
- Mongoose select fields to return from findOneAndUpdate
- mongoose recursive populate
- Heroku app crashes after MongoDB updated to 3.0
- Error at connecting to MongoDb Atlas Server