-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Id property is different for same document if using create or find #8
Comments
After looking a little bit in the code it does not look like intended. It looks like it sets the data on the object that gets returned directly but somehow that object (which should contain the whole data) ends up to be just the "id" property. Tried to fix it but do not really understand at all what is going on. Code should work fine as it is. It looks like that there is something between the callback function which is given to "Test.create" and what gets returned to the callback function in "CouchbaseDB.prototype.create". |
Couchbase does this by default, even with the native sdk. the CAS values On Wed, Jan 28, 2015 at 5:41 PM, Jan [email protected] wrote:
_Nolan Dubeau_VP, Engineering, Guardly Corp. |
Hm but even then I would say that it should be consistent. Either it should always just return the id or always that Object. Having to always fix the documents in the app does not sounds like a good idea to me, think the connector should take care about that. One other inconsistency is the "docType" which is once part of the id (create) and once of the document data (find). Also that should probably be the same. As a work around I changed in my local version the callback in "CouchbaseDB.prototype.create" from:
to
This fixes at least the problem with the id but not the docType. And to be honest because the result is actually just the "id" I have currently not the slightest idea how we could fix that. Ah yes the CAS gets changed whenever the document changes for optimistic locking. So I can read the document, change something and write it back. It can then compare the CAS value and only writes it if they match. If they are different it means the value has changed inbetween and the chance that something would be overwritten is quite high (or almost certain). So I guess that is something the connector should take care about and the loopback application does not have to care about at all. Only then when I write something and the CAS does not match. In that case the connector should probably return an error that the document has changed in the meantime and then the loopback application has to handle that. |
Sorry take back the the last few sentences. Was stupid, did not think that through at all. It is true that the cas is not "directly" needed in the application itself but it has to get passed through back to the save because the connector can not really cache it or anything like that. So created issue #10 that the cas always gets returned but not as part of the id. |
Not sure if that is on purpose but the document id value I get when creating and finding the same document is different.
If I for example create a new Test document the id property is an object:
but if I then query it I get what I would have expected:
I would say it should always return the id as a string and not an object.
The text was updated successfully, but these errors were encountered: