Socket
Socket
Sign inDemoInstall

@oridune/epic-odm

Package Overview
Dependencies
3
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.70 to 1.1.0

2

package.json
{
"name": "@oridune/epic-odm",
"version": "1.0.70",
"version": "1.1.0",
"description": "Install 1 ODM and code once with any database driver.",

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

@@ -243,16 +243,14 @@ "use strict";

const createIndexes = async (collection, indexes, prefix) => {
// Resolve Indexes
const Indexes = typeof indexes === "function" ? indexes() : indexes;
// Create Indexes
const IndexNames = Object.keys(Indexes);
const IndexNames = Object.keys(indexes);
if (IndexNames.length)
await collection.createIndexes(IndexNames.map((name) => {
var _a;
const PartialFilters = (_a = Indexes[name].options) === null || _a === void 0 ? void 0 : _a.partialFilterExpression;
return Object.assign(Object.assign({ name: `${prefix ? prefix + "." : ""}${name}`, key: Indexes[name].columns.reduce((fields, field) => (Object.assign(Object.assign({}, fields), { [`${prefix ? prefix + "." : ""}${field.replace(/^-/, "")}`]: Indexes[name].type === "text"
const PartialFilters = (_a = indexes[name].options) === null || _a === void 0 ? void 0 : _a.partialFilterExpression;
return Object.assign(Object.assign({ name: `${prefix ? prefix + "." : ""}${name}`, key: indexes[name].fields.reduce((fields, field) => (Object.assign(Object.assign({}, fields), { [`${prefix ? prefix + "." : ""}${field.replace(/^-/, "")}`]: indexes[name].type === "text"
? "text"
: /^-/.test(field)
? -1
: 1 })), {}), unique: Indexes[name].type === "unique", background: true }, (typeof Indexes[name].ttl === "number"
? { expireAfterSeconds: Indexes[name].ttl }
: 1 })), {}), unique: indexes[name].type === "unique", background: true }, (typeof indexes[name].ttl === "number"
? { expireAfterSeconds: indexes[name].ttl }
: {})), (typeof PartialFilters === "object"

@@ -274,6 +272,24 @@ ? {

// Create Main Indexes
await createIndexes(Collection, options.indexes);
await createIndexes(Collection, await (typeof options.indexes === "function"
? options.indexes()
: options.indexes));
// Create Text Indexes
if (options.textIndexFields instanceof Array) {
const Fields = options.textIndexFields.filter((field) => typeof field === "string");
if (Fields.length)
await createIndexes(Collection, {
FullTextSearch: {
fields: Fields,
type: "text",
},
});
}
// Create Sub Indexes
for (const Embed of Object.values(options.embeds))
await createIndexes(Collection, (0, model_1.getModelOptions)(Embed.model).indexes, Embed.options.name);
for (const Embed of Object.values(options.embeds)) {
const RawIndexes = (0, model_1.getModelOptions)(Embed.model).indexes;
const ResolvedIndexes = await (typeof RawIndexes === "function"
? RawIndexes()
: RawIndexes);
await createIndexes(Collection, ResolvedIndexes, Embed.options.name);
}
});

@@ -280,0 +296,0 @@ // Initialization

@@ -10,3 +10,3 @@ import { BaseModel } from "../model/base";

type?: Indexes;
columns: (keyof M | `-${Exclude<keyof M, symbol>}`)[];
fields: (keyof M | `-${Exclude<keyof M, symbol>}`)[];
ttl?: number;

@@ -22,3 +22,4 @@ options?: {

arbitrary?: boolean;
indexes: Record<string, IndexInterface<M>> | (() => Record<string, IndexInterface<M>>);
indexes: Record<string, IndexInterface<M>> | (() => Promise<Record<string, IndexInterface<M>>> | Record<string, IndexInterface<M>>);
textIndexFields?: string[];
onInit?: () => any;

@@ -25,0 +26,0 @@ fields: Record<string, FieldInterface>;

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc