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

@oridune/epic-odm

Package Overview
Dependencies
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oridune/epic-odm - npm Package Compare versions

Comparing version 1.0.36 to 1.0.37

4

package.json
{
"name": "@oridune/epic-odm",
"version": "1.0.36",
"version": "1.0.37",
"description": "Install 1 ODM and code once with any database driver.",
"main": "./src/index.js",
"scripts": {
"test": "jest",
"test": "jest --runInBand",
"test:direct": "ts-node -T ./test/index.ts"

@@ -9,0 +9,0 @@ },

@@ -84,4 +84,2 @@ "use strict";

}));
else
throw new Error(`Invalid object has been provided! Unable to validate.`);
return Item;

@@ -88,0 +86,0 @@ }));

@@ -34,3 +34,3 @@ import { Operator, TComparisonOperators, TRangeOperators, TMutationOperators, TCheckOperators, TOtherOperators, ValueType } from "../operators";

protected Cache?: FieldsList;
static createFieldsList(model: typeof BaseModel, fields: string[] | FieldsList, select?: number, embedMode?: boolean): FieldsList;
static createFieldsList(model: typeof BaseModel, fields: string[] | FieldsList, select?: number, embedMode?: boolean, level?: number): FieldsList;
constructor(Model: M, Fields?: string[] | FieldsList);

@@ -37,0 +37,0 @@ getModel(): M;

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

}
static createFieldsList(model, fields, select = 0, embedMode = false) {
static createFieldsList(model, fields, select = 0, embedMode = false, level = 0) {
const ModelOptions = (0, model_1.getModelOptions)(model);

@@ -20,3 +20,3 @@ const ModelKeys = [

const ModelRelationKeys = Object.keys(ModelOptions.relations);
const createFieldSchema = (fieldsList) => {
const createFieldSchema = (fieldsList, resolveMode = false) => {
const SelectableKeysLength = Object.keys(fieldsList).filter((key) => [...ModelKeys, ...ModelEmbedKeys].includes(key) &&

@@ -30,8 +30,7 @@ typeof fieldsList[key] === "number" &&

: undefined)) !== null && _a !== void 0 ? _a : (SelectableKeysLength ? select : select ? 0 : 1), _id: 1 });
// @ts-ignore
if (embedMode)
delete Fields["_id"];
return Fields;
}, {});
if (!embedMode) {
if (embedMode)
delete FieldsList["_id"];
else {
ModelEmbedKeys.forEach((key) => {

@@ -41,2 +40,4 @@ const SubFieldsList = fieldsList[key];

FieldsList[key] = 0;
else if (resolveMode && typeof SubFieldsList === "number")
FieldsList[key] = SubFieldsList;
else

@@ -53,3 +54,3 @@ FieldsList[key] = ModelProjection.createFieldsList(ModelOptions.embeds[key].model, typeof SubFieldsList === "object" ? SubFieldsList : {}, typeof SubFieldsList === "number"

: 1
: select, true);
: select, true, level + 1);
});

@@ -63,13 +64,16 @@ ModelRelationKeys.forEach((key) => {

else if (SubFieldsList)
FieldsList[key] = ModelProjection.createFieldsList(ModelOptions.relations[key].reference(), typeof SubFieldsList === "object" ? SubFieldsList : {}, typeof SubFieldsList === "number"
? SubFieldsList
? 0
: 1
: typeof SubFieldsList === "object"
? 0
: SelectableKeysLength
? select
? 0
: 1
: select);
if (resolveMode && typeof SubFieldsList === "number")
FieldsList[key] = SubFieldsList;
else
FieldsList[key] = ModelProjection.createFieldsList(ModelOptions.relations[key].reference(), typeof SubFieldsList === "object" ? SubFieldsList : {}, typeof SubFieldsList === "number"
? SubFieldsList
? 0
: 1
: typeof SubFieldsList === "object"
? 0
: SelectableKeysLength
? select
? 0
: 1
: select, false, level + 1);
});

@@ -80,8 +84,2 @@ }

const resolveFieldsList = (fields) => {
const FieldsList = fields instanceof Array
? fields.reduce((fieldsList, field) => {
const Exclude = /^-/.test(field);
return Object.assign(Object.assign({}, fieldsList), { [Exclude ? field.replace(/^-/, "") : field]: Exclude ? 0 : 1 });
}, {})
: fields;
const transpose = (object) => {

@@ -106,5 +104,10 @@ const Result = {};

};
return transpose(FieldsList);
return fields instanceof Array
? transpose(fields.reduce((fieldsList, field) => {
const Exclude = /^-/.test(field);
return Object.assign(Object.assign({}, fieldsList), { [Exclude ? field.replace(/^-/, "") : field]: Exclude ? 0 : 1 });
}, {}))
: fields;
};
return createFieldSchema(resolveFieldsList(fields));
return createFieldSchema(resolveFieldsList(fields), !(fields instanceof Array) && !level);
}

@@ -111,0 +114,0 @@ getModel() {

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