UNPKG

spincycle

Version:

A reactive message router and object manager that lets clients subscribe to object property changes on the server

212 lines (184 loc) 5.8 kB
// Generated by CoffeeScript 1.9.3 (function() { var RethinkPersistence, debug, defer, r, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; r = require('rethinkdb'); defer = require('node-promise').defer; debug = process.env["DEBUG"]; RethinkPersistence = (function() { var madr, mport; if (process.env['CRATEDB_HOST']) { madr = process.env['CRATEDB_HOST']; } else { madr = '127.0.0.1'; } mport = process.env['CRATEDB_PORT_28015_TCP_PORT'] || '28015'; function RethinkPersistence(dburl, DB) { this.dburl = dburl; this.DB = DB; this.remove = bind(this.remove, this); this.set = bind(this.set, this); this.search = bind(this.search, this); this.findQuery = bind(this.findQuery, this); this.findMany = bind(this.findMany, this); this.find = bind(this.find, this); this.get = bind(this.get, this); this.count = bind(this.count, this); this.all = bind(this.all, this); this.extend = bind(this.extend, this); this.getDbFor = bind(this.getDbFor, this); this._dogetDBFor = bind(this._dogetDBFor, this); this.listenForChanges = bind(this.listenForChanges, this); this.getConnection = bind(this.getConnection, this); this.connect = bind(this.connect, this); this.connection = void 0; this.dbs = []; } RethinkPersistence.prototype.connect = function() { var ccc, q; console.log('connect called... dburl = ' + this.dburl); q = defer(); ccc = this.dburl || { host: madr, port: mport }; return q; }; RethinkPersistence.prototype.getConnection = function() {}; RethinkPersistence.prototype.listenForChanges = function(table) { return table.changes().run(this.connection).then((function(_this) { return function(cursor) {}; })(this)); }; RethinkPersistence.prototype._dogetDBFor = function(_type) { var q, type; q = defer(); type = _type.toLowerCase(); return q; }; RethinkPersistence.prototype.getDbFor = function(_type) { var q; q = defer(); if (!this.connection) { this.connect().then((function(_this) { return function() { return _this._dogetDBFor(_type).then(function(db) { return q.resolve(db); }); }; })(this)); } else { this._dogetDBFor(_type).then((function(_this) { return function(db) { return q.resolve(db); }; })(this)); } return q; }; RethinkPersistence.prototype.extend = function(_type, id, field, def) { var q; q = defer(); return q; }; RethinkPersistence.prototype.all = function(_type, query, cb) { var type; type = _type.toLowerCase(); if (debug) { console.log('-Rethink.all called for ' + type); } return this.getDbFor(type).then((function(_this) { return function(db) {}; })(this)); }; RethinkPersistence.prototype.count = function(_type) { var q, type; if (debug) { console.log('Rethink.count called'); } type = _type.toLowerCase(); q = defer(); return q; }; RethinkPersistence.prototype.get = function(_type, id, cb) { var type; type = _type.toLowerCase(); return this.getDbFor(type).then((function(_this) { return function(db) {}; })(this)); }; RethinkPersistence.prototype.find = function(_type, property, _value) { return this.findMany(_type, property, _value); }; RethinkPersistence.prototype.findMany = function(_type, _property, _value) { var property, q, type, value; if (debug) { console.log('Rethink.findMany called'); } property = _property || ""; value = _value || ""; if (value) { value = value.toString(); value = value.replace(/[^\w\s@.-]/gi, ''); } q = defer(); type = _type.toLowerCase(); this.getDbFor(type).then((function(_this) { return function(db) {}; })(this)); return q; }; RethinkPersistence.prototype.findQuery = function(_type, query) { var q, type; if (debug) { console.log('Rethink findQuery called for type ' + _type); } if (debug) { console.dir(query); } if (!query.property) { query.property = 'name'; } q = defer(); type = _type.toLowerCase(); this.getDbFor(type).then((function(_this) { return function(db) {}; })(this)); return q; }; RethinkPersistence.prototype.search = function(_type, property, _value) { var q, value; if (debug) { console.log('Rethink.search called'); } value = _value || ""; if (value) { value = value.toString(); value = value.replace(/[^\w\s@.]/gi, ''); } console.log('Rethink search called for type ' + _type + ' property ' + property + ' and value ' + value); q = defer(); this.getDbFor(type).then((function(_this) { return function(db) {}; })(this)); return q; }; RethinkPersistence.prototype.set = function(_type, obj, cb) { var type; type = _type.toLowerCase(); return cb(); }; RethinkPersistence.prototype.remove = function(_type, obj, cb) { var id, type; if (debug) { console.log('Rethink.remove called'); } type = _type.toLowerCase(); id = obj.id; return cb(result); }; return RethinkPersistence; })(); module.exports = RethinkPersistence; }).call(this); //# sourceMappingURL=CrateConnector.js.map