umutbozkurt/django-rest-framework-mongoengine

mongoengine partial update document

ecomdevsolutions opened this issue · 3 comments

How can I update the document partially from view?
I used partial_update() SQL databases such as PostGreSQL, MySQL
but I am not sure how can I update mongoDB document with several properties.

i.e when mongo query is like below, how can I write in Django rest framework view.
db.products.update(
{ _id: 100 },
{ $set:
{
quantity: 500,
details: { model: "14Q3", make: "xyz" },
tags: [ "coats", "outerwear", "clothing" ]
}
}
)

I'm afraid, partial updates are not entirely stable. See test_partial.py for examples.

@BurkovBA no way to update document partially?

No, there is a way, PATCH requests, but their handling might contain bugs. If you run into them - you're welcome to introduce your fixes as Pull Requests.