Ejemplo n.º 1
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) Find(q map[string]interface{}) ([]map[string]interface{}, error) {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	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
	}
	isl := convert.Clean(res).([]interface{})
	ret := []map[string]interface{}{}
	for _, v := range isl {
		ret = append(ret, v.(map[string]interface{}))
	}
	ret = convert.Recurs(ret, toGeneral).([]map[string]interface{})
	return ret, nil
}
Ejemplo n.º 2
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) FindOne(q map[string]interface{}) (map[string]interface{}, error) {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	var res interface{}
	err := s.db.C(s.coll).Find(q).One(&res)
	if err != nil {
		return nil, err
	}
	ret := convert.Clean(res).(map[string]interface{})
	return convert.Recurs(ret, toGeneral).(map[string]interface{}), nil
}
Ejemplo n.º 3
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) UpdateAll(q map[string]interface{}, updQuery map[string]interface{}) (int, error) {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	updQuery = convert.Recurs(updQuery, fromGeneral).(map[string]interface{})
	chi, err := s.db.C(s.coll).UpdateAll(q, updQuery)
	return chi.Updated, err
}
Ejemplo n.º 4
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) Update(q map[string]interface{}, updQuery map[string]interface{}) error {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	updQuery = convert.Recurs(updQuery, fromGeneral).(map[string]interface{})
	return s.db.C(s.coll).Update(q, updQuery)
}
Ejemplo n.º 5
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) Insert(d map[string]interface{}) error {
	d = convert.Recurs(d, fromGeneral).(map[string]interface{})
	return s.db.C(s.coll).Insert(d)
}
Ejemplo n.º 6
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) Count(q map[string]interface{}) (int, error) {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	return s.db.C(s.coll).Find(q).Count()
}
Ejemplo n.º 7
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) RemoveAll(q map[string]interface{}) (int, error) {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	chi, err := s.db.C(s.coll).RemoveAll(q)
	return chi.Removed, err
}
Ejemplo n.º 8
0
Archivo: set.go Proyecto: Laller/nocrud
func (s *Set) Remove(q map[string]interface{}) error {
	q = convert.Recurs(q, fromGeneral).(map[string]interface{})
	return s.db.C(s.coll).Remove(q)
}