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.5.7 to 0.5.9

lib/database_tools.js

2

lib/connection_queries.js
// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.5.7
backbone-mongo.js 0.5.9
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.5.7
backbone-mongo.js 0.5.9
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

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

(function() {
var CONNECTION_QUERIES, Connection, ConnectionPool, DatabaseUrl, MongoClient, Queue, _,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var CONNECTION_QUERIES, Connection, ConnectionPool, DatabaseUrl, MongoClient, Queue, _;

@@ -36,3 +35,2 @@ _ = require('underscore');

}
this.ensureIndex = __bind(this.ensureIndex, this);
if (!_.isString(this.url)) {

@@ -94,18 +92,2 @@ throw new Error('Expecting a string url');

Connection.prototype.ensureIndex = function(field_name, table_name) {
var index_info;
index_info = {};
index_info[field_name] = 1;
return this._collection.ensureIndex(index_info, {
background: true
}, (function(_this) {
return function(err) {
if (err) {
return new Error("MongoBackbone: Failed to indexed '" + field_name + "' on " + table_name + ". Reason: " + err);
}
return console.log("MongoBackbone: Successfully indexed '" + field_name + "' on " + table_name);
};
})(this));
};
Connection.prototype._connect = function() {

@@ -135,23 +117,6 @@ var queue;

return _this.db.collection(_this.collection_name, function(err, collection) {
var field, key, relation, _ref, _ref1, _results;
if (!err) {
_this._collection = collection;
}
callback(err);
_ref = _this.schema.fields;
for (key in _ref) {
field = _ref[key];
if (field.indexed) {
_this.ensureIndex(key, _this.collection_name);
}
}
_ref1 = _this.schema.relations;
_results = [];
for (key in _ref1) {
relation = _ref1[key];
if (relation.type === 'belongsTo' && !relation.isVirtual() && !relation.isEmbedded()) {
_results.push(_this.ensureIndex(relation.foreign_key, _this.collection_name));
}
}
return _results;
return callback(err);
});

@@ -158,0 +123,0 @@ };

// Generated by CoffeeScript 1.7.1
/*
backbone-mongo.js 0.5.7
backbone-mongo.js 0.5.9
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.5.7
backbone-mongo.js 0.5.9
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.5.7
backbone-mongo.js 0.5.9
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.5.7
backbone-mongo.js 0.5.9
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.5.7
backbone-mongo.js 0.5.9
Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-mongo

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

(function() {
var Backbone, Connection, DESTROY_BATCH_LIMIT, ModelCache, ModelTypeID, MongoCursor, MongoSync, QueryCache, Queue, Schema, Utils, moment, util, _;
var Backbone, Connection, DESTROY_BATCH_LIMIT, DatabaseTools, ModelCache, ModelTypeID, MongoCursor, MongoSync, QueryCache, Queue, Schema, Utils, moment, util, _,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -37,2 +38,4 @@ util = require('util');

DatabaseTools = require('./database_tools');
DESTROY_BATCH_LIMIT = 1000;

@@ -44,2 +47,3 @@

this.sync_options = sync_options;
this.db = __bind(this.db, this);
this.model_type.model_name = Utils.findOrGenerateModelName(this.model_type);

@@ -197,42 +201,3 @@ this.model_type.model_id = ModelTypeID.generate(this.model_type);

MongoSync.prototype.resetSchema = function(options, callback) {
var queue;
queue = new Queue();
queue.defer((function(_this) {
return function(callback) {
return _this.collection(function(err, collection) {
if (err) {
return callback(err);
}
return collection.remove(function(err) {
if (options.verbose) {
if (err) {
console.log("Failed to reset collection: " + collection.collectionName + ". Error: " + err);
} else {
console.log("Reset collection: " + collection.collectionName);
}
}
return callback(err);
});
});
};
})(this));
queue.defer((function(_this) {
return function(callback) {
var key, relation, schema, _ref;
schema = _this.model_type.schema();
_ref = schema.relations;
for (key in _ref) {
relation = _ref[key];
if (relation.type === 'hasMany' && relation.reverse_relation.type === 'hasMany') {
(function(relation) {
return queue.defer(function(callback) {
return relation.findOrGenerateJoinTable().resetSchema(callback);
});
})(relation);
}
}
return callback();
};
})(this));
return queue.await(callback);
return this.db().resetSchema(options, callback);
};

@@ -296,2 +261,6 @@

MongoSync.prototype.db = function() {
return this.db_tools || (this.db_tools = new DatabaseTools(this));
};
MongoSync.prototype._selectAdapter = function() {

@@ -298,0 +267,0 @@ var field_info, field_name, info, _i, _len, _ref;

{
"name": "backbone-mongo",
"version": "0.5.7",
"version": "0.5.9",
"description": "MongoDB storage for BackboneORM",

@@ -24,17 +24,16 @@ "main": "./lib/index.js",

"coffee-script": "*",
"codo": "1.7.x",
"mocha": "*",
"powerset": "0.0.x",
"backbone-rest": "0.5.x",
"supertest": "0.7.x",
"express": "3.2.x"
"supertest": "*",
"express": "3.x"
},
"dependencies": {
"underscore": "1.5.x",
"backbone": ">=1.0.0",
"underscore": "1.x",
"backbone": "1.x",
"backbone-orm": "0.5.x",
"moment": "2.x",
"inflection": "1.x",
"mongodb": "1.3.x"
"mongodb": "1.x"
}
}
Please refer to the following release notes when upgrading your version of BackboneORM.
### 0.5.9
* Added database indexing through database tools (Model.db().ensureSchema(callback) or Model.db().resetSchema(callback))
### 0.5.8
* Update dependencies
### 0.5.7

@@ -4,0 +10,0 @@ * Bug fix for RegEx

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