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.15 to 0.0.16

2

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

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

@@ -31,3 +31,3 @@ const GenerateModel = require('./XMongoModel');

if (typeof successCallback === 'function')
successCallback(this);
return successCallback(this);

@@ -68,3 +68,3 @@ }).catch((err) => {

/**
*
* Creates a model using current connection
* @param collection

@@ -71,0 +71,0 @@ * @return {typeof XMongoModel}

@@ -392,2 +392,49 @@ const XMongoUsing = require('./XMongoUsing');

/**
* Unset a key or keys from this collection
* @param {string|[]} keys - Key or Keys to unset from collection
* @param {Object} options - Update options
*/
XMongoModel.prototype.unset = function (keys, options = {}) {
// Throw Error if keys is undefined
if (!keys)
throw Error('Unset key or keys is required.');
// Throw Error if keys is not a string or array
if (typeof keys !== "string" && typeof keys !== "object")
throw Error('Unset key or keys must be typeof (String|Array)');
// Setup $unset object
const $unset = {};
// Change keys to Array if its a string
if (typeof keys === "string") keys = [keys];
// Loop Through and add to $unset object
for (const key of keys) {
$unset[key] = 1
}
// Run MongoDb query and return response in Promise
return new Promise((resolve, reject) => {
return collection.updateOne(
{_id: this.id()},
{$unset},
{},
(error, res) => {
if (error) return reject(error);
// Remove keys from current data
for (const key of keys) {
this.toCollection().unset(key);
}
return resolve(res)
}
)
});
};
/**
* Validate

@@ -651,3 +698,3 @@ * @description

XMongoModel.prototype.emptyData = function (replaceWith=undefined) {
XMongoModel.prototype.emptyData = function (replaceWith = undefined) {
this.data = {

@@ -657,3 +704,3 @@ _id: this.id()

if(replaceWith && typeof replaceWith === 'object') this.data = {...this.data, ...replaceWith};
if (replaceWith && typeof replaceWith === 'object') this.data = {...this.data, ...replaceWith};

@@ -660,0 +707,0 @@ return this;

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