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

cosa

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosa - npm Package Compare versions

Comparing version 3.0.11 to 3.0.12

6

lib/db.js

@@ -75,3 +75,3 @@ const debug = require('debug')('cosa:db');

}
// so we dont mess up people environment variables.
// so we don't mess up people environment variables.
const dbName = options.dbName || getDbName(this._uri);

@@ -253,3 +253,3 @@ debug(`connecting to database: ${this._uri}`);

* @param {boolean} [options.explain=false] - Should should the execution plan be returned.
* @returns {Promise} resovles with the result of the aggregatation from mongo
* @returns {Promise} resolves with the result of the aggregation from mongo
* @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate}

@@ -277,3 +277,3 @@ */

* @param {object} [options] - Optional settings see mongo documentation
* @returns {Promise} resovles with the result of the distinct query from mongo
* @returns {Promise} resolves with the result of the distinct query from mongo
* @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#distinct}

@@ -280,0 +280,0 @@ */

@@ -11,3 +11,4 @@ const assign = require('object-assign');

const errors = require('./errors');
const { pathEq, complement, pathOr, pick, omit } = require('omnibelt');
const { ObjectID } = require('bson');
const { pathEq, complement, pick, omit } = require('omnibelt');

@@ -123,3 +124,4 @@ const { buildPropertySchema } = require('./utils');

const _saveHelper = async function(context, options) {
const _saveHelper = async function(context, options = {}, explicitId) {
options = defaults(options, { waitAfterSave: false });
if (!context.isNew() && !context.isModified()) {

@@ -130,3 +132,3 @@ return context;

if ('function' === typeof context.beforeSave) {
await context.beforeSave.apply(obj);
await context.beforeSave.apply(obj, [options]);
}

@@ -155,3 +157,3 @@ obj = await context._validate(obj, options);

obj._etag = newEtag;
if (options.canPassID && options._id) { obj._id = options._id; }
if (explicitId) { obj._id = explicitId; }
debug(`inserting into ${collection}: ${JSON.stringify(obj)}`);

@@ -165,6 +167,4 @@ const result = await db.insert(collection, obj);

// should not be awaited
const afterSave = newOrUpdatedModel.afterSave(original || null);
if (pathOr(false, ['waitAfterSave'], options)) {
await afterSave;
}
const afterSave = newOrUpdatedModel.afterSave(original || null, options);
if (options.waitAfterSave) { await afterSave; }
}

@@ -283,4 +283,3 @@ return newOrUpdatedModel;

definition.methods.save = async function(options) {
options = Object.assign(options || {}, { canPassID: false });
return _saveHelper(this, options);
return _saveHelper(this, options, null);
};

@@ -292,4 +291,3 @@

}
options = Object.assign(options || {}, { canPassID: true, _id: id });
return _saveHelper(this, options);
return _saveHelper(this, options, new ObjectID(id));
};

@@ -302,3 +300,3 @@

if ('function' === typeof this.beforeRemove) {
await this.beforeRemove();
await this.beforeRemove(options);
}

@@ -312,6 +310,4 @@ debug(`removing ${JSON.stringify(query)} in ${collection}`);

if ('function' === typeof this.afterRemove) {
const afterRemove = this.afterRemove();
if (options.waitAfterRemove) {
await afterRemove;
}
const afterRemove = this.afterRemove(options);
if (options.waitAfterRemove) { await afterRemove; }
}

@@ -318,0 +314,0 @@ return result;

{
"name": "cosa",
"version": "3.0.11",
"version": "3.0.12",
"description": "Cosa Models for MongoDB",

@@ -5,0 +5,0 @@ "main": "lib/index.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