rest-query-engine icon indicating copy to clipboard operation
rest-query-engine copied to clipboard

Support for limit(count,start,maxCount) and sort(<+|-><property)

Open michaelassraf opened this issue 9 years ago • 5 comments

Hi,

This library is awesome 👍 .

It would be nice to have to these two features :

  1. sort(<+|-><property) - Sorts by the given property in order specified by the prefix (+ for ascending, - for descending)
  2. limit(count,start,maxCount) - Returns the given range of objects from the result set

As described here https://github.com/persvr/rql.

Is there a way to allow parentheses syntax like this : eq(foo,3)&lt(price,10) instead of this : foo=3&price=lt=10

Last question, why in examples like the one above they use one = sign for equality in here we use two == ?

Thanks, Michael

michaelassraf avatar Jul 13 '16 12:07 michaelassraf

Hi Michael,

I think you're confusing RQL with RSQL. Unfortunately, RSQL is a subset of the capabilities provided by RQL. That said, I understand that sorting and paging is a useful thing to have.

The thing that originally stopped me from adding them is:

Given that the query is just a string, how can I dictate that the sort and paging get put at the top level of the string (and not in a nested expression where they become rather ambiguous in meaning). I think paging and sort are generally better sent to a rest API as separate parameters, and consequently parsed as a separate expression entirely. That doesn't mean that it wouldn't be useful to define a format for those and provide a parser, however.

I think again the syntactic difference for equality is just a subtle difference between rsql and rql.

If you think having this library parse sort expressions and paging expressions would be useful I'm happy to explore that. I have some mechanisms I've used in the past for expressing sorts that would probably work here and keep with the minimalism of rsql.

RutledgePaulV avatar Jul 18 '16 13:07 RutledgePaulV

Hi,

Yeah I understand the difficulty in determination whether the parentheses represent nested condition or sort/paging function, and I actually did send both of them in a different GET params.

What I had in mind is to define two special keys for that purpose. The developer will have the ability to change the names of the fields (if he specifically wants to use those reserved names as names in his app) through a configuration edit.

What do u think ?

Thanks, Michael

michaelassraf avatar Jul 18 '16 13:07 michaelassraf

I think paging/sorting/limit can be separate parameters that are appended to the critiera. Not sure these are needed as part of the rsql expression.

matthew-b-payne avatar Sep 22 '16 16:09 matthew-b-payne

Sounds like we're all in agreement - @michaelassraf is just asking that this library standardize on some parameter names and provide a parser for those parameters into sort expressions for the various datastores I think.

RutledgePaulV avatar Sep 22 '16 18:09 RutledgePaulV

Yeah through my confusion between RQL and RSQL I borrowed some elements. Anyway I think it will be nice to have full query support, while limit and sort are usually pretty viable part of the query. As said I'm also currently implementing it with different params.

On Sep 22, 2016 9:15 PM, "Paul Rutledge" [email protected] wrote:

Sounds like we're all in agreement - @michaelassraf https://github.com/michaelassraf is just asking that this library standardize on some parameter names and provide a parser for those parameters into sort expressions for the various datastores I think.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RutledgePaulV/rest-query-engine/issues/8#issuecomment-248983827, or mute the thread https://github.com/notifications/unsubscribe-auth/AKzsXNEvGQSNfBBBBDFZ9ZPLQtfHS8Ysks5qssXMgaJpZM4JLXYa .

michaelassraf avatar Sep 22 '16 18:09 michaelassraf