triniwiz / nativescript-plugins

Apache License 2.0
80 stars 50 forks source link

Couchbase logical operator #68

Closed pitw closed 3 years ago

pitw commented 3 years ago

Does logical operator work ? Didn't found any example or working code. For me it hasn't any effect on query.

Example:

const results = database.query({
    select: [],
    where: [{ property: 'group', comparison: 'equalTo', value: 'articles', logical: 'and' },
{ property: 'articleNr', comparison: 'like', value: 'demo', logical: 'and' }],
    order: [{ property: 'articleNr', direction: 'desc' }],
    limit: 10,
});

Query either returns nothing or everything. What I'm doing wrong ?

Background: I'm trying to save different kind of "types" (Articles, Adresses...) - thats why I need at least to where operators (first for type, second for specific search query)

pitw commented 3 years ago

Answering myself. Was testing this for hours until I tried Uppercase operators...

In case somebody has similar issues - this one works:

const results = database.query({
    select: [],
    where: [{ property: 'group', comparison: 'equalTo', value: 'articles', logical: 'AND' },
{ property: 'articleNr', comparison: 'like', value: 'demo', logical: 'AND' }],
    order: [{ property: 'articleNr', direction: 'desc' }],
    limit: 10,
});