How to write following query in go using mgo package:
a:{$subtract:[variable,'$created']}
I tried
date := time.Now()
bson.M{
"a":bson.M{
"$subtract":bson.M{date,"$created"}
}
}
but bson.M is a map and asks me for keys ;(
How to write following query in go using mgo package:
a:{$subtract:[variable,'$created']}
I tried
date := time.Now()
bson.M{
"a":bson.M{
"$subtract":bson.M{date,"$created"}
}
}
but bson.M is a map and asks me for keys ;(
the problem is that array would contain time.Time
structure and string
, so it is mixed type array... but i think i found the answer: How to represent an array with mixed types
type list []interface{}
date := time.Now()
sub := list{date, "$created"}
bson.M{
"a":bson.M{
"$subtract":sub
}
}