I have the following query, what I want is to change field value to upper and use in $match condition.
db.getCollection('jobpostings').aggregate([
{"$match":{
"expireDate":{"$gt": ISODate("2018-05-20T08:38:58.812Z")},
"publishDate":{"$lt": ISODate("2018-05-22T00:00:00.000Z")},
"isPublished":true,"isDrafted":false,
"deletedAt":{"$eq":null},"deleted":false,
"blocked":{"$exists":false},
"locations":{"$in":["BALKH"]}
}},
{"$lookup":{
"from":"companies","localField":"company.id","foreignField":"_id","as":"companyDetails"
}},
{"$match":{"companyDetails":{"$ne":[]}}},
{"$sort":{"isFeatured":-1,"publishDate":-1}},
{"$skip":0},{"$limit":12},
{"$project":{
"position":1,"summary":1,"company":1,"publishDate":1,"expireDate":1,"locations":1,"minimumEducation":1,
"workType":1,"skills":1,"contractType":1,"isExtensible":1,"salary":1,"gender":1,"yearsOfExperience":1,
}}
} ])
I want to use $toUpper
with this line "locations":{"$in":["BALKH"]}
, need to change value of locations field to upper and then check inside array.