KinKon
KinKon13mo ago

Is there a convenient way to get the updated document after using the db.patch method?

In my project the method returns undefined instead of the updated object. Maybe this is the expected behavior. The docs aren't explicit on what the method returns. Am I missing something
5 Replies
jamwt
jamwt13mo ago
specify that patch returns Promise<void> aka it returns nothing. so short answer, nope, it does not return the updated document you'd need to db.get after the patch. or just turn the whole pass into a db.get / (modify document) / db.replace, in which case you'd have the updated document in hand
KinKon
KinKonOP13mo ago
Okay thanks Jamie, appreciated
ian
ian12mo ago
As a reminder, since it's in a transaction with Convex's strong isolation guarantees, if you have the object before the patch (e.g. via db.get ) and manually patch it, you'll get the same result as doing db.get after the patch.
KinKon
KinKonOP12mo ago
Thanks for the explanation

Did you find this page helpful?