Qstore "find" usage


fruits.find(true);

select * from fruits;

fruits.find({type: 'apple'});

select * from fruits where type = 'apple';

fruits.find({type: 'apple', color: 'green'});

select * from fruits where type = 'apple' and color = 'red';

fruits.find({type: ['apple', 'pear']});

--variant 1
select * from fruits where type = 'apple' or type = 'pear';

--variant 2
select * from fruits where type in ('apple', 'pear')

fruits.find({color: 'red'}, ['image']);

select image from fruits where color = 'red';

fruits.find({weight: {$gte: 1}}, ['image', 'weight', 'type']);

select image, weight, type from fruits where weight >= 1;

fruits.find([{price: {$lt: 1}}, {color: 'yellow'}]);

select * from fruits where price < 1 or color = 'yellow'

//variant 1
fruits.find({price: {$and: [{$gte: 1}, function (value) {return value % 1 == 0}] }})

//variant 2
fruits.find({$and: [{price: {$gte: 1}}, function (row) {return row.price % 1 == 0}] })

//variant 3
fruits.find({$and: [{price: {$gte: 1}}, {price: function (value) {return value % 1 == 0}} ] })

//variant 4
fruits.find(function (row) { return row.price >= 1 && row.price % 1 == 0})

//variant 5
ActiveData.addOperator('isInt', function (left, right) { var isInt = (left % 1 == 0); return right ? isInt : !isInt})
fruits.find({price: {$gte: 1, $isInt: true}})

select * from fruits where price >= 1 and (price % 1 = 0)

fruits.find({type: /apple/});