mongodb - How to run $and operator in mgo query in Golang -
i want execute following query in mongodb in golang
check_select = bson.m{ "$and": []interface{}{ "shr_key": user_shr_key, "id": uid, "user_history": bson.m{"$elemmatch": bson.m{"action": "stop", "message_id": mid}}, }, } please help... getting following error "index must non-negative integer constant".
the error way initialize array in go:
.... "$and": []interface{}{ "shr_key": user_shr_key, .... go array doesn't accept string index.
anyway, in order solve problem, remove index array initialization , wrap key-value pair in bson.m do, eg:
bson.m{ "$and": []bson.m{ // can try in []interface bson.m{"shr_key": user_shr_key}, bson.m{"id": uid}, bson.m{"user_history": bson.m{"$elemmatch": bson.m{"action": "stop", "message_id": mid}}}, }, }
Comments
Post a Comment