Sumit M Asok
Sumit M Asok

Reputation: 2950

how to do a like query using mgo package for golang

I am trying to do a like query using mgo with no luck.

what I want is a mongodb query similar to

db.organisation.find( { "permalink" : /org.*/ } )

I am still stuck at

sess.DB(db).C(cApp).
    Find(bson.M{"permalink": "org:bms.*"}).
    All(&m)

Upvotes: 7

Views: 8676

Answers (1)

Thundercat
Thundercat

Reputation: 120951

Use bson.Regex to specify a regular expression value using the unmaintained MGO client package.

sess
  .DB(db)
  .C(cApp)
  .Find(bson.M{"permalink": bson.RegEx{"org.*", ""}})
  .All(&m)

Upvotes: 11

Related Questions