$in operator not working
rajasekar-mu opened this issue · comments
Hi ,
I want to execute to match array values in $in operator, referred #500 , but no luck.
Document:
{ "name": "Help", "id":"3ae42ece-98f9-4e1a-811d-91f65dbf5498", "device_type":[1,2,3] , "network":[1,2,3,4,5], "status":1 }
const filter = { status:1,device_type: { $in: [1] } };
let applications = await ApplicationModel.find(filter,{select:'id,name', sort:{name:'ASC'}});
Please let me know if anything is wrong, bcz it was working old versions on below condition
$any: { $expr: [{ $in: { search_expr: 'search_device', target_expr: 'device_type' } }],
$satisfies: { $in: { search_expr: 'search_device', target_expr: [1] } }, }
Recently we are upgraded the couchbase & ottoman new versions, so we facing some API deprecated issues.
Thanks,
@rajasekar-mu try this way:
const filter = {
status: 1,
$any: {
$expr: [{ search: { $in: 'device_type' } }],
$satisfies: { search: 1 },
},
};
to search for more than one device_type use this other way:
const filter = {
status: 1,
$any: {
$expr: [{ search: { $in: 'device_type' } }],
$satisfies: { search: { $in : [1,3] },
},
};
@rajasekar-mu can you please confirm if what @gsi-alejandro suggested works ?
@gsi-alejandro / @AV25242 thank you, its working fine.