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

thinky

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thinky - npm Package Compare versions

Comparing version 1.13.5 to 1.13.6

50

lib/model.js

@@ -234,3 +234,2 @@ var util = require(__dirname+'/util.js');

Model.prototype.ensureIndex = function(name, fn, opts) {

@@ -826,2 +825,51 @@ var self = this;

}
Model.prototype.insert = function(docs) {
var self = this;
var r = self._getModel()._thinky.r;
if (Array.isArray(docs) === false) {
docs = [docs];
}
var p = new Promise(function(resolve, reject) {
var insert = function() {
r.table(self.getTableName()).insert(docs).run().then(function(results) {
if ((results.errors === 0) && (results.inserted === docs.length)) {
try {
var index = 0;
// Set the primary keys
for(var i=0; i<docs.length; i++) {
if (docs[i].hasOwnProperty(self._getModel()._pk) === false) {
docs[i][self._getModel()._pk] = results.generated_keys[index];
index++
}
}
// Create instances of the model
for(i=0; i<docs.length; i++) {
docs[i] = new self(docs[i]);
}
resolve(docs);
}
catch(err) {
reject(err);
}
}
else {
reject(new Error("An error occurred during the batch insert."))
}
}).error(reject);
}
if (self._getModel()._tableReady === true) {
insert();
}
else {
self.once('ready', function() {
insert();
})
}
})
return p;
}
Model.prototype.then = function() {

@@ -828,0 +876,0 @@ var query = new Query(this);

19

lib/thinky.js

@@ -47,2 +47,8 @@ var rethinkdbdash = require('rethinkdbdash');

var r = self.r;
var init = function() {
self._dbReady = true;
for(var i=0; i<self._onDbReady.length; i++) {
self._onDbReady[i]();
}
}
r.dbList().contains(config.db).do(function(result) {

@@ -54,9 +60,10 @@ return r.branch(

)
}).run().then(function(result) {
self._dbReady = true;
for(var i=0; i<self._onDbReady.length; i++) {
self._onDbReady[i]();
}).run().then(init).error(function(error) {
if (error.message.match(/^Database `.*` already exists in/)) {
// Someone created a database between the dbList and the dbCreate
init();
}
}).error(function(error) {
throw error;
else {
throw error;
}
});

@@ -63,0 +70,0 @@ }

{
"name": "thinky",
"version": "1.13.5",
"version": "1.13.6",
"description": "RethinkDB ORM for Node.js",

@@ -5,0 +5,0 @@ "main": "lib/thinky.js",

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