to document with id car1 to Cars bucket.
I tried to rewrite my query but the new query does not work:
SELECT item FROM ['bmw', 'renault'] model
INNER JOIN (SELECT car.* FROM Cars car WHERE meta(car).id = 'car1') item
ON item.model = model
How to fix this query? I also don’t want to use IN, UNNEST operators as I already have just array of objects in my document. Maybe I need to change the document body ?
Thanks for answer
I played with ARRAY a lot. Did something like that(and other things):
SELECT item FROM ['bmw', 'renault'] model
INNER JOIN
(
SELECT ARRAY v FOR v IN (
SELECT car.* FROM Cars car WHERE meta(car).id = 'car1') END ) item
ON item.model = model
However, no results.
[
{
"$1": [
{}
]
}
]
To be honest I am NOT expert in Couchbase Array functionality.
Maybe I missed something.
it is almost as I have(I need) for static car array but with RAW we have double [[]] instead of []. How can we delete extra [] ?
I also try to avoid IN operator as for 500 model it works VERY slowly
car is ARRAY not object, so you can’t do car.* (so use RAW car)
SELECT makes ARRAY and car is array so unnest required.
SELECT item FROM ['bmw', 'renault'] model
INNER JOIN (SELECT RAW c FROM Cars AS car UNNEST car AS c WHERE meta(car).id = 'car1' ) item
ON item.model = model;
Best will be
SELECT item.*
FROM Cars AS car USE KEYS "car1"
UNNEST car AS item
WHERE item.model IN ["bmw", "renault"]
Thanks a million!
It’s works.
I think I had some problems with previous queries as I added initial data manually with help of IDEA without insert operator, but it does not matter now.