Last active
December 26, 2020 21:56
-
-
Save sedataktas/d72c70e0ff3ae3d8632a0229f625e96f to your computer and use it in GitHub Desktop.
UpdateBook in mongodb with golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func UpdateBook(id primitive.ObjectID, pageCount int) error { | |
| filter := bson.D{{"_id", id}} | |
| update := bson.D{{"$set", bson.D{{"page_count", pageCount}}}} | |
| _, err := BooksCollection.UpdateOne( | |
| Ctx, | |
| filter, | |
| update, | |
| ) | |
| return err | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment