What you missed is $or in your query.
Also it can be done in many ways.
Suppose this is your data set.
[
{"Id_Cust": "4145","firstName": "Albade","language": ["English,Nepali"],"degree": []},
{"Id_Cust": "5296","firstName": "Rafael","language": [],"degree": ["Bachelor,Masters"]},
{"Id_Cust": "6192","firstName": "Abdul","language": [],"degree": []}
]
Now, you can do:
db.collection.find({
$or: [
{language: {$exists: true,$not: {$size: 0}}},
{degree: {$exists: true,$not: {$size: 0}}}
]
})
If your fields in array are optional fields use $exists otherwise you can exclude it.
Alternative I
db.collection.find({
$or: [
{language: {$ne: []}},
{degree: {$ne: []}}
]
})
If your fields in array are optional fields use $exists just like in the above query.
Alternative II
db.collection.find({
$or: [
{language: {$gt: []}},
{ degree: {$gt: []}}
]
})
If your fields in array are optional fields use $exists just like in the very first query.
All methods gives same output:
[
{
"Id_Cust": "4145",
"_id": ObjectId("5a934e000102030405000000"),
"degree": [],
"firstName": "Albade",
"language": [
"English,Nepali"
]
},
{
"Id_Cust": "5296",
"_id": ObjectId("5a934e000102030405000001"),
"degree": [
"Bachelor,Masters"
],
"firstName": "Rafael",
"language": []
}
]
So, you can do it in any way.