I have a Couchbase bucket "businesses" of documents, e.g.: business listings, like listing_HomeDepot, listing_Lowes, listing_DansHardware.
Each listing_* doc has a field businessInfo that contains part of the key to another document in the same bucket. E.g., listing_DansHardware has "businessInfo": "3a4tg", and there should be a document with key info_3a4tg. The document info_3a4tg has an "id" field with "3a4tg" in it.
Let's say Dans Hardware closed down and the info_3a4tg document got deleted. I want to select all businesses that are in the bucket, but filter out any businesses with orphaned business info references.
I tried: select * from businesses b1 where b1.category='hardware' and exists (select * from businesses b2 use keys 'info_'||b1.businessInfo)
but that didn't work. I got some "Document key must be string" error. Any tips, please?