Permalink
Browse files

Merge branch 'master' of github.com:masylum/mongolia

  • Loading branch information...
2 parents d65f45b + fd90859 commit 67cc01f9a98a1874c1e8ff49432f50b98eacaa65 @masylum committed Jul 12, 2011
Showing with 14 additions and 2 deletions.
  1. +12 −0 lib/helpers/namespacer.js
  2. +2 −2 lib/model.js
View
@@ -51,6 +51,16 @@ NAMESPACER.addFieldFind = function (visibility, args) {
}
};
+NAMESPACER.addFieldFindOne = function (visibility, args) {
+ var fields = _getFields(visibility);
+
+ if (args.length <= 2) {
+ args.splice(1, 0, { fields: fields });
+ } else {
+ args[1] = _.defaults({ fields: fields }, args[1]);
+ }
+};
+
NAMESPACER.addFieldFindAndModify = function (visibility, args) {
var fields = _getFields(visibility);
@@ -137,6 +147,8 @@ NAMESPACER.filter = function (namespaces, namespace, fn, args) {
if (fn === 'findAndModify') {
NAMESPACER.addFieldFindAndModify(visibility, args);
NAMESPACER.filterUpdate(visibility, args[2]);
+ } else if (fn == 'findOne') {
+ NAMESPACER.addFieldFindOne(visibility, args);
} else if (fn.match(/^find/)) {
NAMESPACER.addFieldFind(visibility, args);
} else if (fn === 'insert') {
View
@@ -55,8 +55,8 @@ module.exports = function (db, collection_name) {
if (error) {
callback(error, null);
} else {
- var parsed_fn = fn.match(/([a-zA-Z]*)(:([a-zA-Z]*))?/); // extract the namespace
- MODEL.collection_proxy.proxy(MODEL, parsed_fn[1], parsed_fn[3], collection, args, callback);
+ var parsed_fn = fn.match(/([a-zA-Z]*)(?::([a-zA-Z]*))?/); // extract the namespace
+ MODEL.collection_proxy.proxy(MODEL, parsed_fn[1], parsed_fn[2], collection, args, callback);
}
});

0 comments on commit 67cc01f

Please sign in to comment.