Skip to content

Instantly share code, notes, and snippets.

@sedataktas
Last active December 26, 2020 21:56
Show Gist options
  • Select an option

  • Save sedataktas/d72c70e0ff3ae3d8632a0229f625e96f to your computer and use it in GitHub Desktop.

Select an option

Save sedataktas/d72c70e0ff3ae3d8632a0229f625e96f to your computer and use it in GitHub Desktop.
UpdateBook in mongodb with golang
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