I am using go lang in the back end and mongoDB as my database.In my mgo pipeline i m selecting some values from my mongoDB. Below is the go lang equivalent condition which is working
if status !="Processing"{
//then select or project the values
}
The mgo query is as follows and this is working
pipe10 := c.Pipe([]bson.M{
{
"$unwind": "$" + type,
},
{
"$match": bson.M{
type + ".status": bson.M{
"$ne": "Processing",
},
},
},
{
"$project": bson.M{
"name": 1,
},
},
},
)
but when i try to add another value for $ne this is not working.This doesnt throw error but just it skips this != condition. Below is the go lang equivalent condition which i need to implement and not working
if status !="Processing" || status !="Denied{
//then select or project the values
}
I tried as following in mgo
1. pipe10 := c.Pipe([]bson.M{
{
"$unwind": "$" + type,
},
{
"$match": bson.M{
type + ".status": bson.M{
"$ne":[]interface{"Processing","Denied"}
},
},
},
{
"$project": bson.M{
"name": 1,
},
},
},
)
2. pipe10 := c.Pipe([]bson.M{
{
"$unwind": "$" + type,
},
{
"$match": bson.M{
type + ".status": bson.M{
"$ne":bson.M{
"$in":[]interface{"Processing","Denied"}
},
},
},
},
},
{
"$project": bson.M{
"name": 1,
},
},
},
)
3. pipe10 := c.Pipe([]bson.M{
{
"$unwind": "$" + type,
},
{
"$match": bson.M{
type + ".status": bson.M{
"$ne":bson.M{
"$or":[]interface{"Processing","Denied"}
},
},
},
},
},
{
"$project": bson.M{
"name": 1,
},
},
},
)
But these are not working.Appreciate any help.Thanks