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

@andrewscwei/mongodb-odm

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@andrewscwei/mongodb-odm - npm Package Compare versions

Comparing version 0.47.0 to 0.48.0

51

build/core/Model.js

@@ -293,6 +293,7 @@ "use strict";

const t = yield this.beforeInsert(doc || (yield this.randomFields()), Object.assign({ strict: true }, options));
debug(`${this.schema.model}.insertOne:`, JSON.stringify(t, null, 0));
debug(`[${this.schema.model}] Inserting new document...`, JSON.stringify(t, null, 0));
const collection = yield this.getCollection();
const results = yield collection.insertOne(t, options).catch(error => { throw error; });
debug(`${this.schema.model}.insertOne results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Inserting new document...`, 'OK');
debug(`[${this.schema.model}] Document insertion result:`, JSON.stringify(results, null, 0));
if (results.result.ok !== 1)

@@ -359,6 +360,7 @@ throw new Error(`[${this.schema.model}] Unable to insert document`);

}
debug(`${this.schema.model}.insertMany:`, JSON.stringify(t, null, 0));
debug(`[${this.schema.model}] Inserting multiple documents...`, JSON.stringify(t, null, 0));
const collection = yield this.getCollection();
const results = yield collection.insertMany(t, options);
debug(`${this.schema.model}.insertMany results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Inserting multiple documents...`, 'OK');
debug(`[${this.schema.model}] Multiple insertion result:`, JSON.stringify(results, null, 0));
if (results.result.ok !== 1)

@@ -404,3 +406,3 @@ throw new Error(`[${this.schema.model}] Unable to insert many documents`);

const [q, u] = (options.skipHooks === true) ? [query, update] : yield this.beforeUpdate(query, update, options);
debug(`${this.schema.model}.updateOne:`, JSON.stringify(q, null, 0), JSON.stringify(u, null, 0), JSON.stringify(options, null, 0));
debug(`[${this.schema.model}] Updating an existing document...`, JSON.stringify(q, null, 0), JSON.stringify(u, null, 0), JSON.stringify(options, null, 0));
if (options.returnDoc === true) {

@@ -412,3 +414,4 @@ if (!is_1.default.plainObject(q)) {

const res = yield collection.findOneAndUpdate(q, u, Object.assign({}, options, { returnOriginal: true }));
debug(`${this.schema.model}.updateOne results:`, JSON.stringify(res, null, 0), JSON.stringify(options, null, 0));
debug(`[${this.schema.model}] Updating an existing document...`, 'OK');
debug(`[${this.schema.model}] Single document update result:`, JSON.stringify(res, null, 0), JSON.stringify(options, null, 0));
if (res.ok !== 1)

@@ -441,3 +444,4 @@ throw new Error(`[${this.schema.model}] Update failed`);

const res = yield collection.updateOne(q, u, options);
debug(`${this.schema.model}.updateOne results:`, JSON.stringify(res, null, 0));
debug(`[${this.schema.model}] Updating an existing document...`, 'OK');
debug(`[${this.schema.model}] Single document update result:`, JSON.stringify(res, null, 0));
if (res.result.ok !== 1)

@@ -508,3 +512,3 @@ throw new Error(`[${this.schema.model}] Unable to update the document`);

const collection = yield this.getCollection();
debug(`${this.schema.model}.updateMany:`, JSON.stringify(q, null, 0), JSON.stringify(u, null, 0), JSON.stringify(options, null, 0));
debug(`[${this.schema.model}] Updating multiple existing documents...`, JSON.stringify(q, null, 0), JSON.stringify(u, null, 0), JSON.stringify(options, null, 0));
if (options.returnDocs === true) {

@@ -531,3 +535,4 @@ const docs = yield this.findMany(q);

}
debug(`${this.schema.model}.updateMany results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Updating multiple existing documents...`, 'OK');
debug(`[${this.schema.model}] Multiple document update result:`, JSON.stringify(results, null, 0));
}

@@ -539,3 +544,4 @@ yield this.afterUpdate(undefined, results);

const results = yield collection.updateMany(q, u, options);
debug(`${this.schema.model}.updateMany results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Updating multiple existing documents...`, 'OK');
debug(`[${this.schema.model}] Multiple document update result:`, JSON.stringify(results, null, 0));
if (results.result.ok !== 1)

@@ -573,7 +579,8 @@ throw new Error(`[${this.schema.model}] Unable to update many documents`);

const q = yield this.beforeDelete(query, options);
debug(`${this.schema.model}.deleteOne:`, JSON.stringify(query, null, 0));
debug(`[${this.schema.model}] Deleting an existing document...`, JSON.stringify(query, null, 0));
const collection = yield this.getCollection();
if (options.returnDoc === true) {
const results = yield collection.findOneAndDelete(q);
debug(`${this.schema.model}.deleteOne results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Deleting an existing document...`, 'OK');
debug(`[${this.schema.model}] Single document deletion result:`, JSON.stringify(results, null, 0));
if (results.ok !== 1)

@@ -588,3 +595,4 @@ throw new Error(`[${this.schema.model}] Unable to delete document`);

const results = yield collection.deleteOne(q, options);
debug(`${this.schema.model}.deleteOne results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Deleting an existing document...`, 'OK');
debug(`[${this.schema.model}] Single document deletion result:`, JSON.stringify(results, null, 0));
if (results.result.ok !== 1)

@@ -647,3 +655,3 @@ throw new Error(`[${this.schema.model}] Unable to delete document`);

const q = yield this.beforeDelete(query, options);
debug(`${this.schema.model}.deleteMany:`, JSON.stringify(q, null, 0));
debug(`[${this.schema.model}] Deleting multiple existing documents...:`, JSON.stringify(q, null, 0));
const collection = yield this.getCollection();

@@ -663,3 +671,4 @@ if (options.returnDocs === true) {

}
debug(`${this.schema.model}.deleteMany results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Deleting multiple existing documents...:`, 'OK');
debug(`[${this.schema.model}] Multiple document deletion result:`, JSON.stringify(results, null, 0));
const m = results.length;

@@ -671,3 +680,4 @@ yield this.afterDelete(results);

const results = yield collection.deleteMany(q, Object.assign({}, options));
debug(`${this.schema.model}.deleteMany results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Deleting multiple existing documents...:`, 'OK');
debug(`[${this.schema.model}] Multiple document deletion result:`, JSON.stringify(results, null, 0));
if (results.result.ok !== 1)

@@ -703,6 +713,7 @@ throw new Error(`[${this.schema.model}] Unable to delete documents`);

const r = yield this.beforeInsert(replacement || (yield this.randomFields()), options);
debug(`${this.schema.model}.replaceOne:`, JSON.stringify(q, null, 0), JSON.stringify(r, null, 0));
debug(`[${this.schema.model}] Replacing an existing document...`, JSON.stringify(q, null, 0), JSON.stringify(r, null, 0));
const collection = yield this.getCollection();
const results = yield collection.findOneAndReplace(q, r, Object.assign({}, options, { returnOriginal: true }));
debug(`${this.schema.model}.replaceOne results:`, JSON.stringify(results, null, 0));
debug(`[${this.schema.model}] Replacing an existing document...`, 'OK');
debug(`[${this.schema.model}] Document replacement result:`, JSON.stringify(results, null, 0));
if (results.ok !== 1)

@@ -856,3 +867,3 @@ throw new Error(`[${this.schema.model}] Unable to find and replace document`);

validateFieldValue_1.default(val, fieldSpecs, validationStrategy);
debug(`[${this.schema.model}] Validating value "${val}" for field <${key}>... OK`);
debug(`[${this.schema.model}] Validating value "${val}" for field <${key}>...`, 'OK');
}

@@ -1165,3 +1176,3 @@ // #3 Check for unique fields only if `ignoreUniqueIndex` is not `true`.

if (field.ref === this.schema.model) {
debug(`Cascade deleting all ${modelName} documents whose "${key}" field is ${docId}`);
debug(`[${this.schema.model}] Cascade deleting all ${modelName} documents whose <${key}> field is <${docId}>`);
yield ModelClass.deleteMany({ [`${key}`]: docId });

@@ -1168,0 +1179,0 @@ }

{
"name": "@andrewscwei/mongodb-odm",
"version": "0.47.0",
"version": "0.48.0",
"description": "ODM for MongoDB",

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

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