我有以下查询,我想要的是将字段值更改为高位并在$ match条件中使用。
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,
}}
} ])
我想将$toUpper
与此行"locations":{"$in":["BALKH"]}
一起使用,需要将locations字段的值更改为upper,然后检查内部数组。