func (s *Set) FindOne(q map[string]interface{}) (map[string]interface{}, error) { var res interface{} err := s.db.C(s.coll).Find(q).One(&res) if err != nil { return nil, err } return convert.Clean(res).(map[string]interface{}), nil }
// Finds he user by name password equality. func namePass(a iface.Filter, name, encoded_pass string) (map[string]interface{}, error) { q := bson.M{ "name": name, "password": encoded_pass, } doc, err := a.AddQuery(q).FindOne() if err != nil { return nil, err } return convert.Clean(doc).(map[string]interface{}), nil }
func (s *Set) Find(q map[string]interface{}) ([]interface{}, error) { c := s.db.C(s.coll).Find(q) if s.skip != 0 { c.Skip(s.skip) } if s.limit != 0 { c.Limit(s.limit) } if len(s.sort) > 0 { c.Sort(s.sort...) } var res []interface{} err := c.All(&res) if err != nil { return nil, err } return convert.Clean(res).([]interface{}), nil }