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

mongoose-sort-encrypted-field

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-sort-encrypted-field - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

47

lib/index.js

@@ -39,12 +39,3 @@ "use strict";

schema["options"].sortEncryptedFieldsOptions = sortEncryptedFieldsOptions;
schema.post("save", async function save(doc, next) {
for (const [fieldName, sortFieldName] of Object.entries(sortFields)) {
await modelsQueue.addJob(`${this.constructor["modelName"]}::${fieldName}::${sortFieldName}`, {
objectId: doc._id,
fieldValue: doc[fieldName],
});
}
next();
});
schema.pre("updateOne", async function preUpdateOne(next) {
async function preUpdateOne(next) {
const update = this.getUpdate();

@@ -62,4 +53,4 @@ for (const fieldName in sortFields) {

next();
});
schema.post("updateOne", async function postUpdateOne(res, next) {
}
async function postUpdateOne(res, next) {
const update = this.getUpdate();

@@ -84,18 +75,13 @@ for (const fieldName in sortFields) {

next();
});
schema.pre("updateMany", async function preUpdateMany(next) {
const update = this.getUpdate();
for (const fieldName in sortFields) {
const sortFieldName = sortFields[fieldName];
if (update["$set"] && update["$set"][sortFieldName]) {
// Bypass middleware internal call for updating any sortFieldName field
break;
}
if (update["$set"] && update["$set"][fieldName]) {
update["$set"][sortFieldName] = null;
}
}
async function postSave(doc, next) {
for (const [fieldName, sortFieldName] of Object.entries(sortFields)) {
await modelsQueue.addJob(`${this.constructor["modelName"]}::${fieldName}::${sortFieldName}`, {
objectId: doc._id,
fieldValue: doc[fieldName],
});
}
next();
});
schema.post("updateMany", async function postUpdateMany(res, next) {
}
async function postUpdateMany(res, next) {
const update = this.getUpdate();

@@ -122,3 +108,10 @@ for (const fieldName in sortFields) {

next();
});
}
schema.pre("updateOne", preUpdateOne);
schema.post("updateOne", postUpdateOne);
schema.pre("findOneAndUpdate", preUpdateOne);
schema.post("findOneAndUpdate", postUpdateOne);
schema.pre("updateMany", preUpdateOne);
schema.post("save", postSave);
schema.post("updateMany", postUpdateMany);
}

@@ -125,0 +118,0 @@ function getModelWithSortEncryptedFieldsPlugin(documentName, schema, pluginOptions) {

{
"name": "mongoose-sort-encrypted-field",
"version": "0.4.3",
"version": "0.4.4",
"description": "Mongoose plugin to enable sorting on encrypted fields",

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

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