-
Notifications
You must be signed in to change notification settings - Fork 102
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
Issue with HttpClient.prototype.exists and secondary indexes #160
Comments
Just to clarify, this is actually about links rather than secondary indexes, or do you see similar behaviour when calling exists with 2i query? |
Hi, yes with links. I think I made a mistake by saying secondary indexes. :) |
The use case here would be to verify if the object the link points to exists? |
Correct. And I think it would be useful to have this with 2i as well. The use case is that you want to check existence of objects in DB without incurring the penalty of querying the entire object. Not sure if it's possible to do with links/2i indices? If it is, it should be bundled in the same API call. |
It could be doable with secondary indexes, as a query only returns a list of keys. With links, though, while you can trigger HEAD requests, it doesn't include any indication of whether or not there is a payload included that lists Riak objects or if the list is empty. |
Agreed. Well if you could implement support for 2i it would be great!! Thanks! |
When using HttpClient.prototype.exists with secondary indexes instead of keys such as
db.exists('mybucket', null, { links: [{tag: 'mytag', bucket: 'mybucket', key: 'mykey'}]}, callback}
it return exists == true even if there are no objects with such links. The reason is that riak returns HTTP 200 with empty array of keys but since code only looks for 401 return code, it mistakenly thinks that the object exists, which is false. Code should check the length or returned key array. So in the case where key == null and object.links is set, (i.e. the user passes a secondary index), perhaps a regular link walk should be done instead or a GET which would return the link list, while maintaining transparency for users.
The text was updated successfully, but these errors were encountered: