如何在mgo查找请求中使用mongo函数?

时间:2019-04-23 16:11:17

标签: go mgo

我正在使用globalsign / mgo,并且在请求中我需要使用一个函数:

function(){return this.image.test('%s')}
// request that I want
db.getCollection('commands').find(function() { return this.image.test('%s'); })

我这样尝试过:

err = r.coll.Find(fmt.Sprintf("function(){return this.image.test('%s')}", image)).One(&t)

但是它需要一个Bson对象:

Failed to parse: filter: "function(){return this.image.test('sonarqube%3A6.5-1')}". 'filter' field must be of BSON type object.

有人知道怎么做吗?

谢谢

0 个答案:

没有答案