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

penseur

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

penseur - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

27

lib/table.js

@@ -67,3 +67,28 @@ // Load Modules

return callback(null, result.generated_keys ? (items instanceof Array ? result.generated_keys : result.generated_keys[0]) : null);
// Single item
if (!Array.isArray(items)) {
return callback(null, items.id !== undefined ? items.id : result.generated_keys[0]);
}
// Items array
var generated = result.generated_keys || [];
if (generated.length === items.length) {
return callback(null, result.generated_keys);
}
// Mixed array
var ids = [];
for (var g = 0, i = 0, il = items.length; i < il; ++i) {
if (items[i].id !== undefined) {
ids.push(items[i].id);
}
else {
ids.push(result.generated_keys[g++]);
}
}
return callback(null, ids);
});

@@ -70,0 +95,0 @@ };

2

package.json
{
"name": "penseur",
"description": "Lightweight RethinkDB wrapper",
"version": "1.4.0",
"version": "1.4.1",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",

@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur",

@@ -267,2 +267,17 @@ // Load modules

it('returns the generate key (existing)', function (done) {
var db = new Penseur.Db('penseurtest');
db.establish(['test'], function (err) {
expect(err).to.not.exist();
db.test.insert({ id: 11, a: 1 }, function (err, keys) {
expect(err).to.not.exist();
expect(keys).to.equal(11);
done();
});
});
});
it('returns the generate keys', function (done) {

@@ -282,2 +297,53 @@

});
it('returns the generate keys when keys are present', function (done) {
var db = new Penseur.Db('penseurtest');
db.establish(['test'], function (err) {
expect(err).to.not.exist();
db.test.insert([{ id: 1, a: 1 }, { a: 2 }], function (err, keys) {
expect(err).to.not.exist();
expect(keys).to.have.length(2);
expect(keys[0]).to.equal(1);
done();
});
});
});
it('returns the generate keys when keys are present (last)', function (done) {
var db = new Penseur.Db('penseurtest');
db.establish(['test'], function (err) {
expect(err).to.not.exist();
db.test.insert([{ a: 1 }, { id: 1, a: 2 }], function (err, keys) {
expect(err).to.not.exist();
expect(keys).to.have.length(2);
expect(keys[1]).to.equal(1);
done();
});
});
});
it('returns the generate keys when keys are present (mixed)', function (done) {
var db = new Penseur.Db('penseurtest');
db.establish(['test'], function (err) {
expect(err).to.not.exist();
db.test.insert([{ a: 1 }, { id: 1, a: 2 }, { id: 2, a: 3 }, { a: 4 }, { a: 5 }, { id: 3, a: 6 }, { id: 4, a: 7 }], function (err, keys) {
expect(err).to.not.exist();
expect(keys).to.have.length(7);
expect(keys[1]).to.equal(1);
expect(keys[2]).to.equal(2);
expect(keys[5]).to.equal(3);
expect(keys[6]).to.equal(4);
done();
});
});
});
});

@@ -284,0 +350,0 @@

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