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

xpress-mongo

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xpress-mongo - npm Package Compare versions

Comparing version 2.0.15 to 2.0.16

4

fn/projection.js

@@ -48,3 +48,3 @@ "use strict";

const omitIdAnd = (omit = []) => {
return { _id: 0, ...exports.omitKeys(omit) };
return { _id: 0, ...(0, exports.omitKeys)(omit) };
};

@@ -63,4 +63,4 @@ exports.omitIdAnd = omitIdAnd;

const omitIdAndPick = (pick = []) => {
return { _id: 0, ...exports.pickKeys(pick) };
return { _id: 0, ...(0, exports.pickKeys)(pick) };
};
exports.omitIdAndPick = omitIdAndPick;
{
"name": "xpress-mongo",
"version": "2.0.15",
"description": "Light Weight ODM for mongoDb",
"version": "2.0.16",
"description": "Light Weight ODM for mongoDb NodeJs",
"main": "index.js",

@@ -11,6 +11,6 @@ "types": "index.d.ts",

"scripts": {
"play": "ts-node-dev --respawn tests/index.ts",
"play": "npx ts-node-dev --respawn tests/index.ts",
"test": "node JapaFile.js",
"test-dev": "nodemon JapaFile.js --watch 'tests/**' --ext 'ts'",
"watch": "tsc --watch",
"test-dev": "npx nodemon JapaFile.js --watch 'tests/**' --ext 'ts'",
"watch": "npx tsc --watch",
"prepublishOnly": "npx tsc"

@@ -23,3 +23,4 @@ },

"keywords": [
"mongodb"
"mongodb",
"odm"
],

@@ -35,4 +36,4 @@ "author": "xpresserjs",

"escape-string-regexp-node": "^1.0.2",
"joi": "^17.4.2",
"mongodb": "4.1.0",
"joi": "^17.5.0",
"mongodb": "4.2.1",
"object-collection": "^2.0.0",

@@ -42,16 +43,15 @@ "uuid": "^8.3.2"

"devDependencies": {
"@types/node": "^16.6.1",
"@types/uuid": "^8.3.1",
"@types/chance": "^1.1.3",
"@types/lodash": "^4.14.172",
"chance": "^1.1.7",
"@types/node": "^16.11.11",
"@types/uuid": "^8.3.3",
"chance": "^1.1.8",
"japa": "^3.1.1",
"nodemon": "^2.0.12",
"ts-node": "^10.2.0",
"nodemon": "^2.0.15",
"ts-node": "^10.4.0",
"ts-node-dev": "^1.1.8",
"typescript": "^4.3.5"
"typescript": "^4.5.2"
},
"engines": {
"node": ">=12.9"
"node": ">=14"
}
}

@@ -1,2 +0,3 @@

declare const _default;
/// <reference types="lodash" />
declare const _default: import("lodash").LoDashStatic;
/**

@@ -3,0 +4,0 @@ * Get Lodash

import ObjectCollection = require("object-collection");
import { ObjectId, Collection, InsertOneResult, DeleteResult, FindOptions, InsertOneOptions, AggregateOptions, AggregationCursor, Filter, UpdateFilter, UpdateOptions, UpdateResult, FindCursor } from "mongodb";
import { AggregateOptions, AggregationCursor, Collection, DeleteResult, Filter, FindCursor, FindOptions, InsertOneOptions, InsertOneResult, ObjectId, UpdateFilter, UpdateOptions, UpdateResult } from "mongodb";
import { PaginationData, StringToAnyObject, XMongoSchema, XMongoSchemaFn, XMongoStrictConfig } from "./CustomTypes";

@@ -455,6 +455,2 @@ declare type FunctionWithRawArgument = (raw: Collection) => FindCursor | AggregationCursor;

protected $isStrict(): boolean | {
/** Model Loaded Relationships
* @private
* @type {*[]}
*/
removeNonSchemaFields?: boolean | undefined;

@@ -466,2 +462,3 @@ };

* @param isStrict
* @param workingData
* @private

@@ -468,0 +465,0 @@ */

@@ -11,3 +11,2 @@ "use strict";

const joi_1 = __importDefault(require("joi"));
const exports_1 = require("object-collection/exports");
/**

@@ -319,7 +318,7 @@ * Get Lodash

if (schema.hasOwnProperty(field)) {
let schemaVal = inbuilt_1.processSchema(schema[field], field);
let schemaVal = (0, inbuilt_1.processSchema)(schema[field], field);
this.schema[field] = schemaVal["schema"];
if (modifyData) {
// Attach default values
const value = this.data[field] || inbuilt_1.defaultValue(this.schema[field]);
const value = this.data[field] || (0, inbuilt_1.defaultValue)(this.schema[field]);
/**

@@ -425,3 +424,3 @@ * If default value is undefined and schema is required set field to undefined.

changes() {
const changes = deep_object_diff_1.diff(this.original, this.data);
const changes = (0, deep_object_diff_1.diff)(this.original, this.data);
const data = {};

@@ -495,10 +494,14 @@ // @ts-ignore

if (id && !this.meta.usingCustomId) {
await inbuilt_1.RunOnEvent("update", this);
let $set, changes = this.changes();
let $setKeys = Object.keys(changes);
if (!$setKeys.length)
await (0, inbuilt_1.RunOnEvent)("update", this);
let $set = {};
const changes = this.changes();
// if no changes then return false
if (!Object.keys(changes).length)
return resolve(false);
// Try to validate changes
try {
$set = { ...changes, ...this.validate(changes) };
$set = this.validate(changes);
// if validated data i.e $set us empty after validation, then return false
if (!Object.keys($set).length)
return resolve(false);
if (this.meta.hasUniqueSchema) {

@@ -508,3 +511,3 @@ await this.$checkUniqueSchema($set);

// Set original to this.
exports_1.Obj(this.original).merge($set);
_.merge(this.original, $set);
}

@@ -524,3 +527,3 @@ catch (e) {

// Run Watch Event
inbuilt_1.RunOnEvent("watch", this, changes);
(0, inbuilt_1.RunOnEvent)("watch", this, changes);
}

@@ -530,3 +533,3 @@ });

else {
await inbuilt_1.RunOnEvent("create", this);
await (0, inbuilt_1.RunOnEvent)("create", this);
// Try to validate new data.

@@ -553,3 +556,3 @@ try {

// Run on created event
inbuilt_1.RunOnEvent("created", this);
(0, inbuilt_1.RunOnEvent)("created", this);
});

@@ -636,3 +639,3 @@ }

// If not defined in schema
this.$throwErrorIfNotDefinedInSchema(field, isStrict);
this.$throwErrorIfNotDefinedInSchema(field, isStrict, data);
}

@@ -711,7 +714,7 @@ }

if (validatorType === "or" &&
!inbuilt_1.runOrValidation(dataValue, schema.validator["or"])) {
!(0, inbuilt_1.runOrValidation)(dataValue, schema.validator["or"])) {
throw new TypeError(validatorError);
}
else if (validatorType === "and" &&
!inbuilt_1.runAndValidation(dataValue, schema.validator["and"])) {
!(0, inbuilt_1.runAndValidation)(dataValue, schema.validator["and"])) {
throw new TypeError(validatorError);

@@ -764,3 +767,3 @@ }

const result = await this.$static().native().deleteOne({ _id });
inbuilt_1.RunOnEvent("deleted", this).finally(() => { });
(0, inbuilt_1.RunOnEvent)("deleted", this).finally(() => { });
return result;

@@ -1324,5 +1327,6 @@ }

* @param isStrict
* @param workingData
* @private
*/
$throwErrorIfNotDefinedInSchema(field, isStrict) {
$throwErrorIfNotDefinedInSchema(field, isStrict, workingData) {
if (isStrict === undefined)

@@ -1341,2 +1345,4 @@ isStrict = this.$isStrict();

delete this.data[field];
if (workingData)
delete workingData[field];
}

@@ -1343,0 +1349,0 @@ else {

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