field must be of BSON type object
Your filter
variable is an array, not an object and a find()
query accepts an object, not an array. Your final filter
object should have this structure, for example
var filter = { "$and": [ { sel: parseInt(query.idx) }, { admn: parseInt(query.idx)} ], "$or": [ { uid: {$exists: false} }, { uid: 0 }, { uid: null} ]}
So you need to change the part
var filter = [];filter.push({$and: andQry});// = [$and : {andQry}, {$or: orQry}];logger.debug("filter : ",filter);
to
var filter = {};filter["$and"] = andQry;filter["$or"] = orQry;logger.debug("filter : ",filter);
Find expected values in the particular date range to get an output by using Find() Keyword , to get all the array of listed outputs use All()
db := GetDB() defer db.Session.Close() var tempMeet []models.Meetings gtQuery := bson.M{"$gt": start} ltQuery := bson.M{"$lt": end} pipe := bson.M{ "$and": []bson.M{ bson.M{"startTime": gtQuery}, bson.M{"endTime": ltQuery}, }, } shared.BsonToJSONPrint(pipe) err := db.C(models.COLLECTIONNAME).Find(pipe).All(&tempMeet) if err != nil { fmt.Println(err) return nil, errors.New(err.Error()) } return tempMeet, nil