Dart Documentationclean_sync.server

clean_sync.server library

A library for data subscription and synchronization in single page applications.

Properties

const String AND #

const String AND = "\$and"

const num ASC #

const num ASC = 1

const num DESC #

const num DESC = -1

const dummyCache #

const dummyCache = const DummyCache()

const String GT #

const String GT = "\$gt"

final Function historyCollectionName #

final Function historyCollectionName =
 (collectionName) => "__clean_${collectionName}_history"

const String LOCK_COLLECTION_NAME #

const String LOCK_COLLECTION_NAME = '__clean_lock'

final Logger logger #

final Logger logger = new Logger('clean_sync')

const String LT #

const String LT = "\$lt"

final int MAX #

final int MAX = pow(2,16) - 1

const num NOLIMIT #

const num NOLIMIT = 0

const num NOSKIP #

const num NOSKIP = 0

const String OR #

const String OR = "\$or"

const String ORDERBY #

const String ORDERBY = "\$orderby"

final int prefix_random_part #

final int prefix_random_part = new Random().nextInt(MAX)

Logger profilingLogger #

Logger profilingLogger = new Logger('profiling')

final PUBLISHER #

final PUBLISHER = new Publisher()

const String PUSH #

const String PUSH = "\$push"

const String QUERY #

const String QUERY = "\$query"

const String SET #

const String SET = "\$set"

const String UNSET #

const String UNSET = "\$unset"

const String VERSION_FIELD_NAME #

const String VERSION_FIELD_NAME = '__clean_version'

Map watches #

Map watches = {}

var watchID #

var watchID = 0

Functions

MongoProvider mpClone(MongoProvider source) #

MongoProvider mpClone(MongoProvider source){
 MongoProvider m = new MongoProvider(source.collection, source._collectionHistory,
     source._lock, source.cache);
 m._selectorList = new List.from(source._selectorList);
 m._sortParams = new Map.from(source._sortParams);
 m._limit = source._limit;
 m._fields = new List.from(source._fields);
 m._excludeFields = new List.from(source._excludeFields);
 return m;
}

List addFieldIfNotEmpty(List fields, String field) #

List addFieldIfNotEmpty(List fields, String field){
 if (fields.isNotEmpty) {
   var res = new List.from(fields)..add(field);
   return res;
 } else {
   return fields;
 }
}

Map slice(Map map, List keys) #

TODO: this function should be tidied up to some utilities class Creates a new Map out of the given map preserving only keys specified in [keys] [map] is the Map to be sliced keys is a list of keys to be preserved

Map slice(Map map, List keys) {
 Map result = {};

 keys.forEach((key) {
   if (map.containsKey(key)) {
     result[key] = map[key];
   }
 });

 return result;
}

String getIdPrefix() #

String getIdPrefix() {
 return PUBLISHER.getIdPrefix();
}

Future handleSyncRequest(request) #

Future handleSyncRequest(request) {
 return PUBLISHER.handleSyncRequest(request);
}

bool isPublished(String collection) #

bool isPublished(String collection) {
 return PUBLISHER.isPublished(collection);
}

void publish(String c, DataGenerator dg, {beforeRequest: null}) #

void publish(String c, DataGenerator dg, {beforeRequest: null}) {
 PUBLISHER.publish(c, dg, beforeRequest: beforeRequest);
}

dynamic logElapsedTime(watchID) #

logElapsedTime(watchID) {
 var watch = watches[watchID][0];
 var identifier = watches[watchID][1];
 profilingLogger.info('$watchID Processing request ($identifier) currently elapsed '
             '${watch.elapsed}.');
}

dynamic stopWatch(watchID) #

stopWatch(watchID) {
 var watch = watches[watchID][0];
 var identifier = watches[watchID][1];
 profilingLogger.info('$watchID Processing request ($identifier) took ${watch.elapsed}.');
 watch.stop();
 watches.remove(watchID);
}

num startWatch(identifier) #

num startWatch(identifier) {
 watchID++;
 watches[watchID] = [new Stopwatch()..start(), identifier];
 profilingLogger.info('$watchID Started processing request ($identifier).');
 return watchID;
}

Abstract Classes

Classes

Typedefs

Exceptions