Hi,
I would like to ask how to do left joins
by checking if a product id matches one of the product ids present on the array of sub document of our invoice document.
So i have a list product of documents
// Product documents
[
{
id: 'product::01',
name: Product 1,
},
{
id: 'product::02',
name: Product 2,
},
{
id: 'product::03',
name: Product 3,
}
]
I also have an invoice document which contains invoice items which is an array of product documents
// invoice document
{
id: 'invoice:01',
invoiceNumber: 'inv-01',
invoiceItems: [
{
{
id: 'product::01',
name: Product 1,
},
{
id: 'product::02',
name: Product 2,
}
}
]
}
My expected result is something like this
// Product documents [ { id: 'product::01', name: Product 1, id: 'invoice:01', invoiceNumber: 'inv-01', }, { id: 'product::02', name: Product 2, id: 'invoice:01', invoiceNumber: 'inv-01', }, { id: 'product::03', name: Product 3, } ]
Hereâs the query that I made but this doesnât seem to work
SELECT meta(products).id, meta(invoices).id
FROMbucket
products
LEFT JOINbucket
invoices
ON meta(invoices).id = âinvoice::01â
AND ANY invoiceItem INinvoices
.invoiceItems SATISFIES invoiceItem.id= meta(products
).id END
WHERE products.type = âproductâ LIMIT 50