Skip to content

Instantly share code, notes, and snippets.

@dmachi
Created December 22, 2010 18:25
Show Gist options
  • Save dmachi/751880 to your computer and use it in GitHub Desktop.
Save dmachi/751880 to your computer and use it in GitHub Desktop.
Example resolve RQL expression
Here are some examples for an idea i had for the depth resolution of items in persevere using rql.
On the clientside, we could translate these functions into a resolve property of the store.get()'s option
parameter (store.get("something", {resolve:[1]}) for example). It would be nice if on the client side we
could decide upon a way to resolve references that will be consistent across implementations, but I'm
still thinking about it. In the mean time, here is the resolve() idea.
Resolutions - These RQL expressions resolve any links contained in an object to the depth identified
by the first parameter. Subsequent parameters are array of properties that should be the
only properties that get resolved at a particular level. ?resolve(depth,depth1list,depth2list,depth3list,...)
//resolve links to a depth of 1
?resolve(1)
//resolve links to a depth of one, but only on the "foo" or "bar" property of any items
?resolve(1,(foo,bar))
//resolve links to a depth of 2
?resolve(2)
/resolve to depth of 2, on the first level resolve foo and bar properties, and the second level resolve everything
?resolve(2,(foo,bar))
/resolve to depth of 2, on the first level resolve everything, and the second level resolve foo and bar
?resolve(2,,(foo,bar))
/resolve to depth of 2, on the first level resolve foo and bar, and on the second level resolve fubar and baz
?resolve(2,(foo,bar),(fubar,baz))
Partial Resolutions- Partial resolutions retrieve a subset of the data to include in the results.
However, instead of using an id property, they instead use $ref to contain
the id and the contain only a subset of the properties they actually contained.
The client can use this data (eg, name) without having to load the whole object,
but will know it is only a partial object becuase its a $ref instead of an id.
Still need to figure out how the api should handle this kind of thing.
// resolve the foo and bar objects to partials containing only their name and description (and of course $ref)
?resolve(1,(foo:(name,description), bar:(name,description)))
// resolve all of bar, but for for just do a partial with the name and descr
?resolve(1,(foo:(name,description), bar))
//resolve all of the links to a depth of one, but only as partial referencese including the name and description
?resolve(1,(:(name,description)))
// resolve all of bar, but for for just do a partial with the name and descr. At the second level, resolve only baz
?resolve(2,(foo:(name,description), bar),baz)
// resolve all of bar, but for for just do a partial with the name and descr. At the second level, resolve only baz's name & desc
?resolve(2,(foo, bar),baz:(name,desc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment