Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-mongo

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-mongo - npm Package Compare versions

Comparing version 0.6.0 to 0.6.2

gulpfile.coffee

97

lib/cursor.js
// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -11,2 +11,3 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

var ARRAY_QUERIES, MongoCursor, sync, _, _adaptIds, _ref, _sortArgsToMongo,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,

@@ -70,2 +71,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; };

function MongoCursor() {
this.aggregate = __bind(this.aggregate, this);
return MongoCursor.__super__.constructor.apply(this, arguments);

@@ -108,2 +110,5 @@ }

}
if (_this._cursor.$unique) {
return _this.aggregate(args[0], $fields, callback);
}
args.push(function(err, cursor) {

@@ -174,2 +179,92 @@ if (err) {

MongoCursor.prototype.aggregate = function(match, $fields, callback) {
return this.connection.collection((function(_this) {
return function(err, collection) {
var field, group_args, group_id_args, pipeline, sort, _i, _j, _len, _len1, _ref1;
if (err) {
return callback(err);
}
pipeline = [];
pipeline.push({
$match: match
});
if (_this._cursor.$sort) {
if (!_.isArray(_this._cursor.$sort)) {
_this._cursor.$sort = [_this._cursor.$sort];
}
sort = {
$sort: _sortArgsToMongo(_this._cursor.$sort, _this.backbone_adapter)
};
pipeline.push(sort);
}
group_id_args = {};
_ref1 = _this._cursor.$unique;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
field = _ref1[_i];
group_id_args[field] = "$" + field;
}
group_args = {
_id: group_id_args
};
$fields = ($fields || []).concat(_this._cursor.$unique);
$fields = _.without($fields, '_id');
for (_j = 0, _len1 = $fields.length; _j < _len1; _j++) {
field = $fields[_j];
group_args[field] = {
$first: "$" + field
};
}
group_args.__id = {
$first: "$" + _this.backbone_adapter.id_attribute
};
pipeline.push({
$group: group_args
});
if (sort) {
pipeline.push(sort);
}
if (_this._cursor.$one || _this.hasCursorQuery('$exists')) {
pipeline.push({
$limit: 1
});
} else if (_this._cursor.$limit) {
pipeline.push({
$limit: _this._cursor.$limit
});
}
if (_this._cursor.$offset) {
pipeline.push({
$skip: _this._cursor.$offset
});
}
if (_this._cursor.$count) {
pipeline.push({
$group: {
_id: null,
count: {
$sum: 1
}
}
});
}
return collection.aggregate(pipeline, {}, function(err, results) {
var result, _k, _len2;
if (err) {
return callback(err);
}
if (_this._cursor.$count) {
return callback(null, results[0].count);
}
for (_k = 0, _len2 = results.length; _k < _len2; _k++) {
result = results[_k];
result.id = result.__id.toString();
delete result._id;
delete result.__id;
}
return callback(null, _this.selectResults(results));
});
};
})(this));
};
return MongoCursor;

@@ -176,0 +271,0 @@

4

lib/index.js
// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -23,3 +23,3 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

publish._.extend(BackboneMongo, publish);
_.extend(BackboneMongo, publish);

@@ -26,0 +26,0 @@ BackboneMongo.modules = {

// Generated by CoffeeScript 1.7.1
(function() {
var BackboneMongo, BackboneORM, configure, superConfigure, _;
var BackboneMongo, BackboneORM, _;
_ = (BackboneORM = require('backbone-orm'))._;
superConfigure = BackboneORM.configure;
BackboneMongo = require('../core');

@@ -13,9 +11,9 @@

module.exports = configure = function(options) {
module.exports = function(options) {
if (options.connection_options) {
_.extend(BackboneMongo.connection_options, options.connection_options);
}
return superConfigure(options);
return BackboneORM.configure(_.omit(options, 'connection_options'));
};
}).call(this);
// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -6,0 +6,0 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -6,0 +6,0 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -6,0 +6,0 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -6,0 +6,0 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.6.0
backbone-mongo.js 0.6.2
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

@@ -28,2 +28,5 @@ License: MIT (http://www.opensource.org/licenses/mit-license.php)

json: true,
unique: true,
manual_ids: true,
dynamic: true,
self_reference: true

@@ -80,5 +83,5 @@ };

MongoSync.prototype.create = function(model, options) {
if (this.manual_id && !model.id) {
return options.error(new Error("Missing manual id for create: " + (JSONUtils.stringify(model.attributes))));
MongoSync.prototype.create = function(model, options, force) {
if (this.manual_id && !force) {
return options.error(new Error("Create should not be called for manual option. Set an id before calling save. Model: " + (JSONUtils.stringify(model.toJSON()))));
}

@@ -108,7 +111,4 @@ return this.connection.collection((function(_this) {

if (!model.get('_rev')) {
return this.create(model, options);
return this.create(model, options, true);
}
if (this.manual_id && !model.id) {
return options.error(new Error("Missing manual id for create: " + (JSONUtils.stringify(model.attributes))));
}
return this.connection.collection((function(_this) {

@@ -251,3 +251,3 @@ return function(err, collection) {

info = field_info[_i];
if (info.manual_id) {
if (info.manual || info.manual_id) {
this.manual_id = true;

@@ -254,0 +254,0 @@ return require('./lib/document_adapter_no_mongo_id');

{
"name": "backbone-mongo",
"version": "0.6.0",
"version": "0.6.2",
"description": "MongoDB storage for BackboneORM",

@@ -8,27 +8,36 @@ "main": "./lib/index.js",

"author": "Kevin Malakoff (https://github.com/kmalakoff)",
"contributors": ["Gwilym Humphreys (https://github.com/gwilymhumphreys)"],
"repository": {"type": "git", "url": "https://github.com/vidigami/backbone-mongo.git"},
"keywords": ["backbone", "orm", "backbone-orm", "mongo", "mongodb"],
"engines": {"node": "*"},
"contributors": [
"Gwilym Humphreys (https://github.com/gwilymhumphreys)"
],
"repository": {
"type": "git",
"url": "https://github.com/vidigami/backbone-mongo.git"
},
"keywords": [
"backbone",
"orm",
"backbone-orm",
"mongo",
"mongodb"
],
"engines": {
"node": "*"
},
"scripts": {
"test": "npm run build && ulimit -n 1024; NODE_ENV=test mocha --require backbone-rest/test/parameters_express4 '{node_modules/backbone-{orm,rest}/,}test/{issues,spec}/**/*.tests.coffee' --grep ''",
"test-quick": "npm run build && ulimit -n 1024; NODE_ENV=test mocha --require backbone-rest/test/parameters_express4 'node_modules/backbone-orm/test/spec/**/*.tests.coffee' --grep '@no_cache @no_embed'",
"test-self": "npm run build && ulimit -n 1024; NODE_ENV=test mocha '{node_modules/backbone-orm/,}test/{issues,spec}/**/*.tests.coffee' --grep ''",
"test-rest": "npm run build && mocha --require backbone-rest/test/parameters_express4 'node_modules/backbone-rest/test/spec/**/*.tests.coffee' --grep ''",
"build": "coffee -o lib -c src",
"watch": "coffee -o lib -w src",
"clean": "rm -rf lib/*",
"prepublish": "npm run build",
"build_dep": "npm run-script backbone-orm build; npm run-script backbone-rest build",
"watch_dep": "npm run-script backbone-orm watch; npm run-script backbone-rest watch"
"test": "ulimit -n 1024; gulp test",
"prepublish": "npm run build"
},
"devDependencies": {
"backbone-rest": "0.6.x",
"body-parser": "1.x",
"chai": "*",
"coffee-script": "*",
"body-parser": "1.x",
"express": "3.x",
"gulp": "*",
"gulp-coffee": "*",
"gulp-mocha": "*",
"gulp-util": "*",
"mocha": "*",
"chai": "*",
"backbone-rest": "0.6.x",
"supertest": "*",
"express": "3.x"
"event-stream": "*",
"supertest": "*"
},

@@ -35,0 +44,0 @@ "dependencies": {

@@ -68,9 +68,15 @@ [![Build Status](https://travis-ci.org/vidigami/backbone-mongo.svg?branch=develop)](https://travis-ci.org/vidigami/backbone-mongo#master)

```
$ npm run build
$ gulp build
```
Please run tests before submitting a pull request.
Please run tests before submitting a pull request:
```
$ gulp test --quick
```
and eventually all tests:
```
$ npm test
```
Please refer to the following release notes when upgrading your version of BackboneORM.
### 0.6.2
* Added dynamic and manual_ids capabilities
### 0.6.1
* Added unique capability
### 0.6.0

@@ -4,0 +10,0 @@ * Upgraded to BackboneORM 0.6.x

@@ -1,2 +0,2 @@

### From 0.5.x to 0.6.0
### From 0.5.x to 0.6.x

@@ -10,3 +10,3 @@ 1. All references to require('backbone-mongo').connection_options should be replaced with configure.

# to
require('backbone-mongo').configure(options)
require('backbone-mongo').configure({connection_options: options})
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc