Permalink
Browse files

Merge git://github.com/persvr/perstore

Conflicts:
	store/mongodb-file.js
  • Loading branch information...
2 parents 604ee55 + 16aa238 commit da2f40b4aaebcf95dc780acf911dd6cc8b4e48db @kriszyp kriszyp committed Mar 21, 2013
Showing with 14 additions and 14 deletions.
  1. +1 −1 facet.js
  2. +5 −5 store/cache.js
  3. +5 −1 store/mongodb-file.js
  4. +3 −7 store/mongodb.js
View
@@ -273,7 +273,7 @@ function FacetedStore(store, facetSchema){
}
if(!directives.id){
// create a new object
- return this.add(props);
+ return this.add(props, directives);
}
else{
// check to see if it is an RPC object
View
@@ -1,8 +1,7 @@
/**
* This is a wrapper store that can add caching to a store
*/
-var table = {},
- when = require("promised-io/promise").when;
+var when = require("promised-io/promise").when;
exports.Cache = function(store, cacheStore, options){
options = options || {};
@@ -11,9 +10,10 @@ exports.Cache = function(store, cacheStore, options){
var cleanupInterval = options.cleanupInterval || 1000;
var lastAccess = {};
var nextCheck = new Date().getTime();
+ var now;
cleanup();
function cleanup(){
- var now = new Date().getTime();
+ now = new Date().getTime();
if(now > nextCheck){
nextCheck = now + cleanupInterval;
return when(cacheStore.query("expires<$1", {parameters:[now]}), function(results){
@@ -29,7 +29,7 @@ exports.Cache = function(store, cacheStore, options){
lastAccess[id] = now++;
if(!cached){
if(store){
- cacheStore.put(cached = store.get[id], {id:id});
+ cacheStore.put(cached = store.get(id), {id:id});
}
}
return cached;
@@ -71,4 +71,4 @@ exports.Cache = function(store, cacheStore, options){
cacheStore["delete"](id);
}
};
-};
+};
@@ -17,10 +17,14 @@ module.exports = function(options){
each(contents.buffer);
};
object["content-type"] = object.type;
+ var disposition = 'attachment';
+ if (object.filename) {
+ disposition += ';filename="' + object.filename + '"';
+ }
var metadata = {
"content-type": object.type,
"content-length": contents.buffer.length,
- "content-disposition": 'attachment',
+ "content-disposition": disposition,
"filename": object.filename
};
metadata.alternates = [object];
View
@@ -24,10 +24,6 @@ var convertNodeAsyncFunction = require('promised-io/promise').convertNodeAsyncFu
var RQ = require("rql/parser");
//RQ.converters["default"] = exports.converters.auto;
-RQ.converters['re'] = function(x){
-dir('RECONV:', x);
- return new RegExp(x, 'i');
-};
// candidate for commonjs-utils?
function dir(){var sys=require('sys');for(var i=0,l=arguments.length;i<l;i++)sys.debug(sys.inspect(arguments[i]));}
@@ -279,7 +275,7 @@ module.exports = function(options){
// .insert() returns array, we need the first element
obj = obj && obj[0];
if (obj) delete obj._id;
- deferred.resolve(obj);
+ deferred.resolve(obj.id);
});
} else {
deferred.reject(id + " exists, and can't be overwritten");
@@ -289,7 +285,7 @@ module.exports = function(options){
collection.update(search, object, {upsert: directives.overwrite}, function(err, obj){
if (err) return deferred.reject(err);
if (obj) delete obj._id;
- deferred.resolve(obj);
+ deferred.resolve(id);
});
}
return deferred;
@@ -384,4 +380,4 @@ module.exports = function(options){
}
}
}
-module.exports.MongoDB = module.exports;
+module.exports.MongoDB = module.exports;

0 comments on commit da2f40b

Please sign in to comment.