Socket
Socket
Sign inDemoInstall

xpress-mongo

Package Overview
Dependencies
229
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.0.2

20

index.d.ts

@@ -29,2 +29,20 @@ import { MongoClient, MongoClientOptions, ObjectId } from "mongodb";

/**
* Create Index Helper
* @param Model - Model to create index for
* @param field - Field/Fields to create index for
* @param unique - If index should be unique
* @param onError - Error callback
* @constructor
*
* @example
* CreateIndex(User, "username"); // Create index for username
* CreateIndex(User, "username", true); // Create index for username
* CreateIndex(User, ["username", "email"]); // Create compound index for username and email
* CreateIndex(User, ["username", "email"], true); // Create compound index for username and email
*/
declare function CreateIndex(Model: typeof XMongoModel, field: string | string[], unique?: boolean, onError?: () => {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
}): void;
/**
* Adds an event to set a fields Timestamp to current date on update.

@@ -34,2 +52,2 @@ * Remove if not in use.

declare function RefreshDateOnUpdate(Model: typeof XMongoModel, field: string, ifHasChanges?: boolean): void;
export { is, Joi as joi, Client, XMongoModel, XMongoTypedModel, XMongoDataType, XMongoSchemaBuilder, XMongoSchema, XMongoSchemaFn, omitKeys, pickKeys, omitIdAnd, omitIdAndPick, parseServerUrl, RefreshDateOnUpdate, ObjectId };
export { is, Joi as joi, Client, XMongoModel, XMongoTypedModel, XMongoDataType, XMongoSchemaBuilder, XMongoSchema, XMongoSchemaFn, omitKeys, pickKeys, omitIdAnd, omitIdAndPick, parseServerUrl, RefreshDateOnUpdate, ObjectId, CreateIndex };

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectId = exports.RefreshDateOnUpdate = exports.parseServerUrl = exports.omitIdAndPick = exports.omitIdAnd = exports.pickKeys = exports.omitKeys = exports.XMongoDataType = exports.XMongoTypedModel = exports.XMongoModel = exports.Client = exports.joi = exports.is = void 0;
exports.CreateIndex = exports.ObjectId = exports.RefreshDateOnUpdate = exports.parseServerUrl = exports.omitIdAndPick = exports.omitIdAnd = exports.pickKeys = exports.omitKeys = exports.XMongoDataType = exports.XMongoTypedModel = exports.XMongoModel = exports.Client = exports.joi = exports.is = void 0;
const mongodb_1 = require("mongodb");

@@ -89,2 +89,35 @@ Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return mongodb_1.ObjectId; } });

/**
* Create Index Helper
* @param Model - Model to create index for
* @param field - Field/Fields to create index for
* @param unique - If index should be unique
* @param onError - Error callback
* @constructor
*
* @example
* CreateIndex(User, "username"); // Create index for username
* CreateIndex(User, "username", true); // Create index for username
* CreateIndex(User, ["username", "email"]); // Create compound index for username and email
* CreateIndex(User, ["username", "email"], true); // Create compound index for username and email
*/
function CreateIndex(Model, field, unique = false, onError = () => console.error) {
let options;
if (unique) {
options = { unique };
}
if (typeof field === "string") {
Model.native()
.createIndex({ [field]: 1 }, options || {})
.catch(onError);
}
else {
const fields = {};
field.forEach((f) => (fields[f] = 1));
Model.native()
.createIndex(fields, options || {})
.catch(onError);
}
}
exports.CreateIndex = CreateIndex;
/**
* Adds an event to set a fields Timestamp to current date on update.

@@ -91,0 +124,0 @@ * Remove if not in use.

2

package.json
{
"name": "xpress-mongo",
"version": "3.0.1",
"version": "3.0.2",
"description": "Light Weight ODM for mongoDb NodeJs",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc