New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

backbone-db

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-db - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

.jshintrc

27

lib/db.js

@@ -116,2 +116,12 @@ var Backbone = require('backbone');

var self = this;
function store(model) {
self.store().setItem(model.get(model.idAttribute), JSON.stringify(model), function (err, res) {
self.records.push(model.get(model.idAttribute));
self.save(function (err) {
return cb(err, model.toJSON(), res);
});
});
}
if (model.isNew()) {

@@ -126,13 +136,6 @@ this.createId(model, options, function (err, id) {

function store(model) {
self.store().setItem(model.get(model.idAttribute), JSON.stringify(model), function (err, res) {
self.records.push(model.get(model.idAttribute));
self.save(function (err) {
return cb(err, model.toJSON(), res);
});
});
}
},
find: function (model, options, cb) {
debug("FIND: " + JSON.stringify(model));
debug('FIND: ' + JSON.stringify(model));
this.store().getItem(model.get(model.idAttribute), function (err, data) {

@@ -144,3 +147,3 @@ data = data && JSON.parse(data);

findAll: function (model, options, cb) {
debug("FINDALL: " + JSON.stringify(options));
debug('FINDALL: ' + JSON.stringify(options));
var self = this;

@@ -167,3 +170,3 @@ var models = [];

destroy: function (model, options, cb) {
debug("DESTROY: " + JSON.stringify(model));
debug('DESTROY: ' + JSON.stringify(model));
var self = this;

@@ -175,3 +178,3 @@ if (model.isNew()) {

self.records = _.reject(self.records, function (id) {
return id == model.get(model.idAttribute);
return id === model.get(model.idAttribute);
});

@@ -178,0 +181,0 @@ self.save(function (err) {

{
"name": "backbone-db",
"version": "0.4.3",
"version": "0.4.4",
"description": "Key-Value database storage interface, localStorage and in-process implementations",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -248,3 +248,3 @@ var Db = require('../');

model.destroy({
success: function (model, response) {
success: function () {
assert(m.length === 2, 'model was not removed from collection');

@@ -261,3 +261,3 @@ m.fetch({

},
error: function () {
error: function (err) {
assert(err);

@@ -264,0 +264,0 @@ },

@@ -1,7 +0,5 @@

var Db = require('../');
var assert = require('assert');
var _ = require('lodash');
var Backbone = require('backbone');
module.exports = function (cb) {
var m;
after(function () {

@@ -26,7 +24,5 @@ if (cb) cb();

var Model = this.Model;
var m = new Model({
id: 1
});
m = new Model();
m.save({
variable: "123",
variable: '123',
counter: 1

@@ -36,8 +32,8 @@ }, {

var m2 = new Model({
id: 1
id: m.get(m.idAttribute)
});
m2.fetch({
success: function () {
assert.equal(m2.get("variable"), "123");
assert.equal(m2.get("counter"), 1);
assert.equal(m2.get('variable'), '123');
assert.equal(m2.get('counter'), 1);
t();

@@ -55,4 +51,4 @@ },

it('should inc Model counter', function (t) {
var m = new this.Model({
id: 1
var m2 = new this.Model({
id: m.get(m.idAttribute)
});

@@ -72,3 +68,3 @@ var opts = {

};
m.save(null, opts);
m2.save(null, opts);
});

@@ -78,8 +74,8 @@

var m2 = new this.Model({
id: 1
id: m.get(m.idAttribute)
});
m2.fetch({
success: function () {
assert.equal(m2.get("variable"), "123");
assert.equal(m2.get("counter"), 3);
assert.equal(m2.get('variable'), '123');
assert.equal(m2.get('counter'), 3);
t();

@@ -95,4 +91,4 @@ },

it('should fail inc operation gracefully', function (t) {
var m = new this.Model({
id: 2
var m2 = new this.Model({
id: m.get(m.idAttribute)+'asd'
});

@@ -105,3 +101,3 @@ var opts = {

ignoreFailures: true,
success: function (model) {
success: function () {
t();

@@ -114,3 +110,3 @@ },

};
m.save(null, opts);
m2.save(null, opts);
});

@@ -120,3 +116,3 @@

var m2 = new this.Model({
id: 1
id: m.get(m.idAttribute)
});

@@ -126,4 +122,4 @@

success: function () {
assert.equal(m2.get("variable"), "123");
assert.equal(m2.get("counter"), 3);
assert.equal(m2.get('variable'), '123');
assert.equal(m2.get('counter'), 3);
m2.destroy({

@@ -130,0 +126,0 @@ success: function () {

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