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 0.0.33 to 0.0.34

6

js/src/XMongoDataType.js

@@ -61,3 +61,9 @@ "use strict";

}
/**
* Set required to false
*/
isOptional() {
return this.required(false);
}
}
module.exports = XMongoDataType;

@@ -131,2 +131,45 @@ "use strict";

/**
* Push element to model
* @param key
* @param value
* @param strict
* @return {this}
*/
pushToArray(key, value, strict = false) {
// Find current value of key
let data = this.get(key, undefined);
// if current value is undefined create new array
if (data === undefined) {
data = [];
}
// Else if not array we throw an error
else if (!Array.isArray(data)) {
throw Error(`PushTo: Current value of {${key}} is not an array.`);
}
// Else if strict and value already exists.
else if (strict && data.includes(value)) {
return this;
}
// push value to array
data.push(value);
// Set data to model
this.set(key, data);
// Return this.
return this;
}
/**
* Find data in array
* @param key
* @param value
*/
findInArray(key, value) {
// Get data value
const data = this.get(key, undefined);
// Return undefined of value is undefined
if (data === undefined)
return data;
// Find in data
return _.find(data, value);
}
/**
* Insert new record and return instance.

@@ -133,0 +176,0 @@ * @param data - new record data.

2

package.json
{
"name": "xpress-mongo",
"version": "0.0.33",
"version": "0.0.34",
"description": "Light Weight ODM for mongoDb",

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

@@ -70,4 +70,11 @@ import {ValidatorType, CastFunctionType, SchemaPropertiesType} from "./CustomTypes";

}
/**
* Set required to false
*/
isOptional() {
return this.required(false);
}
}
export = XMongoDataType;

@@ -180,2 +180,54 @@ import ObjectCollection = require('object-collection');

/**
* Push element to model
* @param key
* @param value
* @param strict
* @return {this}
*/
pushToArray(key: string, value: any, strict: boolean = false): this {
// Find current value of key
let data: any[] = this.get(key, undefined);
// if current value is undefined create new array
if (data === undefined) {
data = [];
}
// Else if not array we throw an error
else if (!Array.isArray(data)) {
throw Error(`PushTo: Current value of {${key}} is not an array.`);
}
// Else if strict and value already exists.
else if (strict && data.includes(value)) {
return this;
}
// push value to array
data.push(value);
// Set data to model
this.set(key, data);
// Return this.
return this;
}
/**
* Find data in array
* @param key
* @param value
*/
findInArray(key: string, value: any): any {
// Get data value
const data = this.get(key, undefined);
// Return undefined of value is undefined
if (data === undefined) return data;
// Find in data
return _.find(data, value);
}
/**
* Insert new record and return instance.

@@ -182,0 +234,0 @@ * @param data - new record data.

@@ -34,3 +34,7 @@ import { ValidatorType, CastFunctionType, SchemaPropertiesType } from "./CustomTypes";

isUndefined(): this;
/**
* Set required to false
*/
isOptional(): this;
}
export = XMongoDataType;

@@ -91,2 +91,16 @@ import ObjectCollection = require('object-collection');

/**
* Push element to model
* @param key
* @param value
* @param strict
* @return {this}
*/
pushToArray(key: string, value: any, strict?: boolean): this;
/**
* Find data in array
* @param key
* @param value
*/
findInArray(key: string, value: any): any;
/**
* Insert new record and return instance.

@@ -93,0 +107,0 @@ * @param data - new record data.

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