ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
680 stars 55 forks source link

Update by Id #11

Closed gamedolphin closed 2 years ago

gamedolphin commented 2 years ago

Couldn't find a documented way of doing so.

ostafen commented 2 years ago

You are right. There is no method for this. I will add it. Thank you

ostafen commented 2 years ago

@gamedolphin I correct myself. In section "Update and Delete documents" it is shown how to update documents matching a given criteria.

So you could simply achieve this by the following code:

db.Query("dbname").Where(c.Field("_id").Eq(docId)).Update(updates)

where updates is your update map, and docId is the id of your document. Probably, it's better to put this example in the README to give evidence that each document has an "_id" field

gamedolphin commented 2 years ago

Thank you for the clarification. Cheer!