Пример #1
0
func newIterator(query Query) model.Iterator {
	mgoQuery, err := query.mongoQuery()
	if err != nil {
		return model.NewErrorIterator(err)
	}
	mgoIter := mgoQuery.Iter()
	collection, selectors := collectionAndSubDocumentSelectors(query)
	return &MongoIterator{collection: collection, selectors: selectors, iter: mgoIter}
}
Пример #2
0
// Returns an iterator of dereferenced refs, or an error iterator if there was an error
func DereferenceIterator(refs ...Ref) model.Iterator {
	docs := make([]interface{}, len(refs))
	for i := range refs {
		var err error
		docs[i], err = refs[i].Get()
		if err != nil {
			err = errs.Format("%s: %s", refs[i].ID.Hex(), err.Error())
			return model.NewErrorIterator(err)
		}
	}
	return model.NewObjectIterator(docs...)
}
Пример #3
0
func (self *Collection) TryDocumentWithIDIterator(id bson.ObjectId, subDocSelectors ...string) model.Iterator {
	if len(subDocSelectors) > 0 {
		panic("Sub document selectors are not implemented")
	}
	document, ok, err := self.TryDocumentWithID(id, subDocSelectors...)
	if err != nil {
		return model.NewErrorIterator(err)
	}
	if !ok {
		return model.NewObjectIterator()
	}
	return model.NewObjectIterator(document)
}
Пример #4
0
func (self *QueryError) Iterator() model.Iterator {
	return model.NewErrorIterator(self.Err)
}