Is it possible to create a general query that will work for different types of documents? For example, I have "cases" and "factories". They have a different set of fields. eg:
{
id: 'case_o1',
name: 'Case numero uno',
amount: 40
}
{
id: 'factory_002',
location: 'Venezuela',
workers: 200,
operating: true
}
Is it possible to create a general query in which I would pass the type of an object (case or factory) and additional parameters, and it will filter the results based on this data? I could, of course, use a javascript representation, but this does not allow me to filter by multiple fields. Let's say I want to pick up all the plants located in Venezuela, with the number of workers from 20 to 55 years.
I started with this, but then I got stuck:
select * from `mybucket` as entity
where position(meta(entity).id, $entity_type) == 0
How to pass several predicates and receive a request for their recognition?
I can, of course, specify the following fields:
where position(meta(entity).id, $entity_type) == 0
and entity.location == 'Venezuela'
and entity.workers > $workers_min
and entity.workers < $workers_max
but then
- - , , , $works_min $workers_max, , ( )?
- Couchbase, , api
- , , "" args, undefined (,
WHERE $location IS MISSING OR entity.location == $location
- )
, ? ?