So i’m trying to pass dynamic query to mongodb, which required that embeded documents are passed in as strings. How do I pass on skills.skill such that it’s evaluated as a string and yet contains the next part of arguments.
The query is that collection.find({‘skills.skill’: {$and: [{$or: [{level: 1}]}, {$or: [{level: not 2}]}]}}).
for (var a in combined) { //combined filters
z[a] = {$and: [{$or: []}]}
//state for what operation; if just equals or not equals
//make sure that there's no empty $or statement for it-as if both
var q = true
for (var b in combined[a].levels) {
if(combined[a].levels[b] == true) {
//default
if (!q || z[a].$or.length == 1) {
q = false
z[a].$or[0].push({$and: [combined[a].levels[b]: {$eq: b}]})
} else {
if (z[a].$or.length()==1) z[a].$or.push({$and: []})
z[a].$or[1].$and.push({$and: [combined[a].levels[b]: {$eq: b}]})
}
} else {
if (z[a].$or.length == 2 || q) {
z[a].$or[0].push({$or: [combined[a].levels[b]: {$ne: b}]})
} else {
if (z[a].$or.length()==1) z[a].$or.push({$and: []})
z[a].$or[1].push({$or: [combined[a].levels[b]: {$ne: b}]})
}
}
}