Closed sebflaesch closed 8 years ago
Hi @sebflaesch With the current stable (1.1.x) implementation the way to add the ETag in your case is to PATCH the resource: this way the ETag will be added. The problem here you can't PATCH with empty data, so you must overwrite an existing property with the same value.
For example, let's say you have this document:
{
"_id": "134444",
"_links": {
"curies": [],
"self": {
"href": "/db/coll/134444"
}
},
"message": "MongoDB rocks as well!",
"name": "Andrea"
}
If update the name this way (using httpie): http -j PATCH http://dbapi.io/db/coll/134444 name='Andrea'
Then the _etag gets added:
{
"_etag": {
"$oid": "5699029006a38f0006affc02"
},
"_id": "134444",
"_links": {
"curies": [],
"self": {
"href": "/db/coll/134444"
}
},
"message": "MongoDB rocks as well!",
"name": "Andrea"
}
But honestly this is awkward... Besides you'll receive a HTTP 409 error response (See: https://softinstigate.atlassian.net/browse/RH-149) despite the document being updated correctly.
We totally agree not everybody needs the optimistic concurrency control with ETags, so we are working to make it optional in release 1.2.0. Please feel free to contribute your comments here: https://softinstigate.atlassian.net/browse/RH-147
I also agree we need to review the documentation afterwards for better clarity.
Thanks for this fast and clear answer... will deal with this, I am just doing a study... Seb
Hi @sebflaesch
just to let you know that I just completed the optional etag checking feature https://softinstigate.atlassian.net/browse/RH-147
it will be released with restheart 1.2, if you want to play with it now you can clone and build the project.
enjoy :)
Hi,
I would like to query / update through RESTHeart some collections/documents that were created directly from mongo shell... But from my understanding, this is not possible because documents need an _etag field to be updated. Correct?
=> How can I add _etag fields to existing documents? => Or is there a way to update documents that were not created through RESTHeart API, if I don't care about optimistic concurrency control with etags?
The documentation lacks some clear examples... to me the "API Tutorial" is incomplete, and the "API reference" has empty Example sections.
Thanks. Seb