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

iridium

Package Overview
Dependencies
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iridium - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

test/config.js

45

lib/Model.js

@@ -137,27 +137,50 @@ /// <reference path="../nodelib/node.js"/>

Model.prototype.insert = Model.prototype.create = function (object, callback) {
/// <signature>
/// <summary>Inserts the given object into the database</summary>
/// <param name="object" type="Object">The properties to set on the newly created object</param>
/// <param name="callback" type="Function"></param>
/// <param name="callback" type="Function">A function to be called once the object has been created</param>
/// </signature>
/// <signature>
/// <summary>Inserts the given object into the database</summary>
/// <param name="object" type="Array" elementType="Object">An array of objects representing the properties to set on the newly created objects</param>
/// <param name="callback" type="Function">A function to be called once the objects have been created</param>
/// </signature>
var $ = this;
var doInsert = function(err) {
if(err) return callback(err);
if(!Array.isArray(object)) object = [object];
var created = [];
var next = function(err, instance) {
if(err) return callback(err, created);
if(instance) created.push(instance);
if(object.length === 0) {
$.setupIndexes();
return callback(null, created);
}
var toInsert = object.shift();
doHook(toInsert);
}
var doInsert = function(err, object, next) {
if(err) return next(err);
var validation = validate($.options.schema, object);
if (!validation.passed) return callback(validation.toError());
if (!validation.passed) return next(validation.toError());
var instance = $.wrap.call($, object, true);
instance.save(callback);
$.setupIndexes();
instance.save(next);
};
if (this.options.hooks.beforeCreate) {
var doHook = function(object) {
if (this.options.hooks.beforeCreate) {
if (this.options.hooks.beforeCreate.length === 0) this.options.hooks.beforeCreate.call(object);
else return this.options.hooks.beforeCreate.call(object, doInsert);
}
else return this.options.hooks.beforeCreate.call(object, doInsert);
}
};
doInsert();
next();
};

@@ -164,0 +187,0 @@

{
"name": "iridium",
"version": "1.3.2",
"version": "1.3.3",
"author": "Benjamin Pannell <admin@sierrasoftworks.com>",

@@ -5,0 +5,0 @@ "description": "A custom lightweight ORM for MongoDB designed for power-users",

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