jugglingdb icon indicating copy to clipboard operation
jugglingdb copied to clipboard

Add support for advanced queries.

Open freezy opened this issue 11 years ago • 3 comments

If I've understood this correctly, as of now only AND conditions are available. Even simple logical OR expressions are not supported (at least not in a generic way).

I find model's approach quite attractive and since its basic syntax is identical to jugglingdb's, I propose the following syntax:

// Where "foo" is 'BAR' OR "bar" is 'BAZ'
{or: [{foo: 'BAR'}, {bar: 'BAZ'}]}

// Where "foo" is not 'BAR' OR "bar" is null OR "baz" is less than 2112
{or: [{foo {ne: 'BAR'}}, {bar: null}, {baz: {lt: 2112}}]}

With negation:

// Where NOT ("foo" is 'BAR' and "bar" is 'BAZ')
{not: {foo: 'BAR', bar: 'BAZ'}}

// Where NOT ("foo" is 'BAZ' and "bar" is less than 1001)
{not: {foo: 'BAZ', bar: {lt: 1001}}}

And nested queries:

// Where ("foo" is like 'b' OR "foo" is 'foo') and NOT "foo" is 'baz'
{or: [{foo: {'like': 'b'}}, {foo: 'foo'}], not: {foo: 'baz'}}

In my opinion, at least basic OR conditions are quite essential for an ORM. If this could somehow be addressed, that would be great.

freezy avatar Apr 04 '13 10:04 freezy