Exposing _rev and _id from the API

14 views
Skip to first unread message

Jiaudheen Abdul Malick

unread,
Nov 2, 2015, 8:28:04 AM11/2/15
to OADA Developers Group
Hi, 
  I have gone through the updated document and found "resources/{resourceId}/_rev" and "resources/{resourceId}/_id" would return the revision and id respectively for that resources. Here comes few doubts and the following are those,

  1. Same like above,is it applicable to get _rev and _id via bookmark also ? i.e. bookmarks/irrigation/machines/_rev or bookmark/irrigation/machines/_id should also return revision and id respectively, where machine is resource and it has an unique id ?
  
  2. Is it applicable to get _rev and _id for the sub document as well, for ex. resources/abc123 responds with,

  { 
    _id : abc123,
    _rev : 2-qwrert,
    _meta : { metaId : abc123, _rev : 2-qwrert },
    device : 
        {
            _id : xyz123, _rev : 4-ertwd
        },
    name : pivot, 
    status : running
  }

 and resources/abc123/_rev would return "2-qwrert" . In the same way is it applicable to get the _rev of device via resources/abc123/device/_rev which should return "4-ertwd" ?

3. Also in the above example response, there are name and status property. Do we need to get those properties also exposed ?
  i.e. via  resources/abc123/name and resources/abc123/status which would return "pivot" and "running" respectively.


Thanks,
Jiaudheen A

Andrew Balmos

unread,
Nov 2, 2015, 1:08:57 PM11/2/15
to Jiaudheen Abdul Malick, OADA Developers Group
Jiaudheen,


On Mon, Nov 2, 2015 at 8:28 AM, Jiaudheen Abdul Malick <jiau...@gmail.com> wrote:
  1. Same like above,is it applicable to get _rev and _id via bookmark also ? i.e. bookmarks/irrigation/machines/_rev or bookmark/irrigation/machines/_id should also return revision and id respectively, where machine is resource and it has an unique id ?

Yes because /bookmarks/irrigation/machines maps to the top of some resource. It is the same as requesting /resources/abc123/_rev or /resources/abc123/_id if /resources/abc123 is the resource /bookmarks/irrigation/machines points to.
  
  2. Is it applicable to get _rev and _id for the sub document as well, for ex. resources/abc123 responds with,

  { 
    _id : abc123,
    _rev : 2-qwrert,
    _meta : { metaId : abc123, _rev : 2-qwrert },
    device : 
        {
            _id : xyz123, _rev : 4-ertwd
        },
    name : pivot, 
    status : running
  }

 and resources/abc123/_rev would return "2-qwrert" . In the same way is it applicable to get the _rev of device via resources/abc123/device/_rev which should return "4-ertwd" ?

Correct. /resources/abc123/device/_rev should return "4-ertwd". /resources/abc123/device resolves to /resources/xyz123 and so /resources/abc123/device/_rev is the same as /resources/xyz123/_rev.
 
3. Also in the above example response, there are name and status property. Do we need to get those properties also exposed ?
  i.e. via  resources/abc123/name and resources/abc123/status which would return "pivot" and "running" respectively.

Yes, every key in a JSON document should be accessible directly via their JSON pointer URL (which is exactly what you wrote).
 
Andrew

Aaron Ault

unread,
Nov 2, 2015, 11:17:20 PM11/2/15
to Andrew Balmos, Jiaudheen Abdul Malick, OADA Developers Group
Just to add another way of looking at it, within an OADA-conformant API you can append any key from any response to the URL and get just that part of the response.  If '/bookmarks/irrigation/machines' returns a document that contains an '_id' key, then '/bookmarks/irrigation/machines/_id' is a valid URL that will return just the value of '_id' . 

This is, in fact, what the test suite does: whenever it gets a response, it tries to get each key of that response by appending it to the URL.  And then it does that for the responses that come back to those requests.  And so on recursively.  

Are you currently able to run the existing test suite as you are developing?

Aaron



--
You received this message because you are subscribed to the Google Groups "OADA Developers Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oada-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages