ObjectoryCollectionDirectConnectionImpl class
class ObjectoryCollectionDirectConnectionImpl extends ObjectoryCollection{
ObjectoryDirectConnectionImpl objectoryImpl;
ObjectoryCollectionDirectConnectionImpl(this.objectoryImpl);
Future<int> count([ObjectoryQueryBuilder selector]) {
return objectoryImpl.db.collection(collectionName).count(selector);
}
Future<List<PersistentObject>> find([ObjectoryQueryBuilder selector]){
Completer completer = new Completer();
var result = objectory.createTypedList(classType);
objectoryImpl.db.collection(collectionName)
.find(selector)
.each((map){
PersistentObject obj = objectory.map2Object(classType,map);
result.add(obj);
}).then((_) {
if (selector == null || !selector.paramFetchLinks) {
completer.complete(result);
} else {
Future
.wait(result.map((item) => item.fetchLinks()))
.then((res) {completer.complete(res);});
}
});
return completer.future;
}
Future<PersistentObject> findOne([ObjectoryQueryBuilder selector]){
Completer completer = new Completer();
objectoryImpl.db.collection(collectionName)
.findOne(selector)
.then((map){
objectoryImpl.completeFindOne(map,completer,selector, classType);
});
return completer.future;
}
}
Extends
ObjectoryCollection > ObjectoryCollectionDirectConnectionImpl
Constructors
new ObjectoryCollectionDirectConnectionImpl(ObjectoryDirectConnectionImpl objectoryImpl) #
Properties
ObjectoryDirectConnectionImpl objectoryImpl #
ObjectoryDirectConnectionImpl objectoryImpl
Methods
Future<int> count([ObjectoryQueryBuilder selector]) #
Future<int> count([ObjectoryQueryBuilder selector]) {
return objectoryImpl.db.collection(collectionName).count(selector);
}
Future<List<PersistentObject>> find([ObjectoryQueryBuilder selector]) #
Future<List<PersistentObject>> find([ObjectoryQueryBuilder selector]){
Completer completer = new Completer();
var result = objectory.createTypedList(classType);
objectoryImpl.db.collection(collectionName)
.find(selector)
.each((map){
PersistentObject obj = objectory.map2Object(classType,map);
result.add(obj);
}).then((_) {
if (selector == null || !selector.paramFetchLinks) {
completer.complete(result);
} else {
Future
.wait(result.map((item) => item.fetchLinks()))
.then((res) {completer.complete(res);});
}
});
return completer.future;
}
Future<PersistentObject> findOne([ObjectoryQueryBuilder selector]) #
Future<PersistentObject> findOne([ObjectoryQueryBuilder selector]){
Completer completer = new Completer();
objectoryImpl.db.collection(collectionName)
.findOne(selector)
.then((map){
objectoryImpl.completeFindOne(map,completer,selector, classType);
});
return completer.future;
}
Future<PersistentObject> get(ObjectId id) #
inherited from ObjectoryCollection
Future<PersistentObject> get(ObjectId id) => objectory.findInCacheOrGetProxy(id, this.classType).fetch();