Complex queries in ember-data

Hi, folks

Is there some especification or recommendation to perform queries in ember-data using operators, like: and, or, like etc. In the source I have found a mention about a “abstract query language”, but I don’t found a example.

Any idea?

I think the idea is that because an ember data query ultimately resolves to a query string, it’s up to your server to decide how to interpret the arguments from the query string that the query serializes to. Query string’s can only represent name/value pairs so if you need to represent complex rules in the query string you’d need to figure out a scheme that works for your case.

Thanks for reply @robmonie

This is very valid for rest adapter, mas I think that ember-data is intended to be used with several sources, like localstorage, indexed db, websql etc.

And if I want to perform a query using “or operator” in my websql adapter, I will create my own pattern. By example:

App.Person.query(" name = 'tom OR framework = 'emberjs' '")

But other person created a localstorage adapter, and he use a other pattern to use the “or operator”.

App.Person.query({ name: "tom", $or: { framework: 'emberjs' } })

If I change the configuration from websql adapter to localstorage adapter, my interface is broken, and I have to change all queries. Instead of only the adapter settings.

ember-data encourage you to use a json for queries. The adapter should convert to underlying format (SQL for example) if needed to. I suppose at some point we could specify a bit the json. “mongo-like” json queries seems like a good start.

But there is a lot of more urgent issues in ember-data, so I would not hold a breath for something too soon.