Here I'm building a query for getting a booking from database and I'm making a query for it but according to conditions I want to build a query and make a condition on the time field that if time is not equal to and less then zero then it will join with the query condition other wise not. following is the condition I'm using and I want to validate the time:-
mongoSession := ConnectDb()
defer mongoSession.Close()
sessionCopy := mongoSession.Copy()
defer sessionCopy.Close()
getCollection := sessionCopy.DB(Database).C(Collection)
condition := bson.M{
"status": 1,
"category": bson.M{"$in": services},
"method": bson.M{"$in": value},
"date": date,
"location": loc,
"end_time": bson.M{"$lte": currTime},
}
I want to validate the end_time
by following:-
if currTime > 0{
"end_time":bson.M{"$lte": currTime},
}
// Something like that
Can anyone tell me how I will perform this?