Comparing version 0.9.6 to 0.9.7
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var BaseAdapter, type; | ||
var BaseAdapter, BaseCollection, merge, type, _ref; | ||
type = require("fairmont").type; | ||
_ref = require("fairmont"), type = _ref.type, merge = _ref.merge; | ||
@@ -28,4 +28,46 @@ BaseAdapter = (function() { | ||
module.exports = BaseAdapter; | ||
BaseCollection = (function() { | ||
function BaseCollection() {} | ||
BaseCollection.prototype.patch = function(key, object) { | ||
var _this = this; | ||
return this.events.source(function(events) { | ||
var _events; | ||
_events = _this.get(key); | ||
_events.on("success", function(data) { | ||
var __events; | ||
if (data != null) { | ||
if (type(data) === "array") { | ||
if (type(object) === "array") { | ||
data = data.concat(object); | ||
} else { | ||
data.push(object); | ||
} | ||
} else if (type(data) === "object") { | ||
data = merge(data, object); | ||
} | ||
} | ||
__events = _this.put(key, data); | ||
__events.on("success", function(data) { | ||
return events.emit("success", data); | ||
}); | ||
return __events.on("error", function(err) { | ||
return events.emit("error", err); | ||
}); | ||
}); | ||
return _events.on("error", function(err) { | ||
return events.emit("error", err); | ||
}); | ||
}); | ||
}; | ||
return BaseCollection; | ||
})(); | ||
module.exports = { | ||
BaseAdapter: BaseAdapter, | ||
BaseCollection: BaseCollection | ||
}; | ||
}).call(this); |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Adapter, BaseAdapter, Collection, ElasticSearchClient, defaults, merge, overload, type, _ref, | ||
var Adapter, BaseAdapter, BaseCollection, Collection, ElasticSearchClient, defaults, merge, overload, type, _ref, _ref1, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -13,3 +13,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
BaseAdapter = require("./base-adapter"); | ||
_ref1 = require("./base-adapter"), BaseAdapter = _ref1.BaseAdapter, BaseCollection = _ref1.BaseCollection; | ||
@@ -84,3 +84,5 @@ defaults = { | ||
Collection = (function() { | ||
Collection = (function(_super) { | ||
__extends(Collection, _super); | ||
Collection.make = function(options) { | ||
@@ -257,3 +259,3 @@ return new this(options); | ||
if (jsonData.error == null) { | ||
return events.emit("success", jsonData); | ||
return events.emit("success", object); | ||
} else { | ||
@@ -269,2 +271,26 @@ return events.emit("error", jsonData.error); | ||
Collection.prototype.patch = function(key, object) { | ||
var _this = this; | ||
return this.events.source(function(events) { | ||
var _events; | ||
_events = _this.get(key); | ||
_events.on("success", function(data) { | ||
var __events; | ||
if (data != null) { | ||
data = merge(data, object); | ||
} | ||
__events = _this.put(key, data); | ||
__events.on("success", function(data) { | ||
return events.emit("success", data); | ||
}); | ||
return __events.on("error", function(err) { | ||
return events.emit("error", err); | ||
}); | ||
}); | ||
return _events.on("error", function(err) { | ||
return events.emit("error", err); | ||
}); | ||
}); | ||
}; | ||
Collection.prototype["delete"] = overload(function(match, fail) { | ||
@@ -283,3 +309,3 @@ match("string", function(key) { | ||
if (jsonData.error == null) { | ||
return events.emit("success"); | ||
return events.emit("success", key); | ||
} else { | ||
@@ -366,3 +392,3 @@ return events.emit("error", jsonData.error); | ||
})(); | ||
})(BaseCollection); | ||
@@ -369,0 +395,0 @@ module.exports = { |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Adapter, BaseAdapter, Collection, type, | ||
var Adapter, BaseAdapter, BaseCollection, Collection, overload, type, _ref, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -9,4 +9,6 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
BaseAdapter = require("./base-adapter"); | ||
overload = require("typely").overload; | ||
_ref = require("./base-adapter"), BaseAdapter = _ref.BaseAdapter, BaseCollection = _ref.BaseCollection; | ||
Adapter = (function(_super) { | ||
@@ -45,3 +47,5 @@ __extends(Adapter, _super); | ||
Collection = (function() { | ||
Collection = (function(_super) { | ||
__extends(Collection, _super); | ||
Collection.make = function(options) { | ||
@@ -57,2 +61,18 @@ return new this(options); | ||
Collection.prototype.find = overload(function(match, fail) { | ||
match("array", function(keys) { | ||
var _this = this; | ||
return this.events.source(function(events) { | ||
var values; | ||
values = keys.map(function(key) { | ||
return _this.collection[key]; | ||
}); | ||
return events.emit("success", values); | ||
}); | ||
}); | ||
return match("string", function(key) { | ||
return this.get(key); | ||
}); | ||
}); | ||
Collection.prototype.get = function(key) { | ||
@@ -88,7 +108,7 @@ var _this = this; | ||
values = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = Object.keys(this.collection); | ||
var _i, _len, _ref1, _results; | ||
_ref1 = Object.keys(this.collection); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
key = _ref[_i]; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
key = _ref1[_i]; | ||
_results.push(this.collection[key]); | ||
@@ -111,3 +131,3 @@ } | ||
})(); | ||
})(BaseCollection); | ||
@@ -114,0 +134,0 @@ module.exports = { |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Adapter, BaseAdapter, Collection, MongoDB, defaults, merge, overload, type, _ref, | ||
var Adapter, BaseAdapter, BaseCollection, Collection, MongoDB, defaults, merge, overload, type, _ref, _ref1, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -13,3 +13,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
BaseAdapter = require("./base-adapter"); | ||
_ref1 = require("./base-adapter"), BaseAdapter = _ref1.BaseAdapter, BaseCollection = _ref1.BaseCollection; | ||
@@ -32,3 +32,3 @@ defaults = { | ||
function Adapter(configuration) { | ||
var database, host, options, port, _ref1, | ||
var database, host, options, port, _ref2, | ||
_this = this; | ||
@@ -38,3 +38,3 @@ this.configuration = configuration; | ||
Adapter.__super__.constructor.call(this, this.configuration); | ||
_ref1 = this.configuration, host = _ref1.host, port = _ref1.port, options = _ref1.options, database = _ref1.database; | ||
_ref2 = this.configuration, host = _ref2.host, port = _ref2.port, options = _ref2.options, database = _ref2.database; | ||
this.events.safely(function() { | ||
@@ -48,3 +48,3 @@ var server; | ||
if (error == null) { | ||
_this.log("MongoAdapter: Connected to MongoDB server @ " + _this.host + ":" + port); | ||
_this.log("MongoAdapter: Connected to MongoDB server @ " + host + ":" + port); | ||
return _this.events.emit("ready", _this); | ||
@@ -85,3 +85,5 @@ } else { | ||
Collection = (function() { | ||
Collection = (function(_super) { | ||
__extends(Collection, _super); | ||
Collection.make = function(options) { | ||
@@ -236,3 +238,3 @@ return new this(options); | ||
})(); | ||
})(BaseCollection); | ||
@@ -239,0 +241,0 @@ module.exports = { |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Adapter, BaseAdapter, Collection, defaults, merge, overload, redis, type, _ref, | ||
var Adapter, BaseAdapter, BaseCollection, Collection, defaults, merge, overload, redis, type, _ref, _ref1, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -13,3 +13,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
BaseAdapter = require("./base-adapter"); | ||
_ref1 = require("./base-adapter"), BaseAdapter = _ref1.BaseAdapter, BaseCollection = _ref1.BaseCollection; | ||
@@ -66,3 +66,5 @@ defaults = { | ||
Collection = (function() { | ||
Collection = (function(_super) { | ||
__extends(Collection, _super); | ||
Collection.make = function(options) { | ||
@@ -124,3 +126,3 @@ return new this(options); | ||
if (err == null) { | ||
return events.emit("success", res); | ||
return events.emit("success", object); | ||
} else { | ||
@@ -138,3 +140,5 @@ return events.emit("error", err); | ||
if (err == null) { | ||
return events.emit("success", res); | ||
return events.emit("success", { | ||
_id: key | ||
}); | ||
} else { | ||
@@ -183,3 +187,3 @@ return events.emit("error", err); | ||
})(); | ||
})(BaseCollection); | ||
@@ -186,0 +190,0 @@ module.exports = { |
{ | ||
"name": "pirate", | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"description": "A simple storage interface with adapters for different storage systems", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# Argh! What's This? | ||
Pirate provides a simple key-value storage interface with adapters for different storage systems. Pirate currently supports MongoDB, Elasticsearch, and in-memory storage. | ||
Pirate provides a simple key-value storage interface with adapters for different storage systems. Pirate currently supports MongoDB, Elasticsearch, Redis and in-memory storage. | ||
@@ -5,0 +5,0 @@ ## Benefits |
36970
928