Пример #1
0
func (f *Filter) SelectOne() (iface.Document, error) {
	q := mergeQuery(f.query, f.parents)
	data, err := f.set.FindOne(q)
	if err != nil {
		return nil, err
	}
	return document.New(f.set, data), nil
}
Пример #2
0
func (f *Filter) Iterate(callback func(iface.Document) error) error {
	f.set.Limit(0)
	q := mergeQuery(f.query, f.parents)
	dataz, err := f.set.Find(q)
	if err != nil {
		return err
	}
	for _, data := range dataz {
		doc := document.New(f.set, data)
		err := callback(doc)
		if err != nil {
			return err
		}
	}
	return nil
}