swell-js
swell-js copied to clipboard
Is it possible to make a 'OR' request with $filter?
I have products like this:
[
{
name: 'Product 1',
attributes: {
width: '15',
height: '20',
channels: ['web', 'mobile']
}
},
{
name: 'Product 2',
attributes: {
width: '25',
height: '30',
},
},
{
name: 'Product 3',
attributes: {
width: '10',
height: '10',
channels: ['web']
}
},
]
I want to filter products without the channels
field OR
a specified channels.
In server side I can achieve this with swell-node
like this:
await swell.get('/products', {
limit: 50,
where: {
active: true,
$or: [
{ 'attributes.channels': { $exists: false } }, // if no channels defined, take the product for everyone
{ 'attributes.channels': { $in: ['web'] } }, // for specified channels
],
},
});
Is it possible to make this OR request with swell-js
?