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

@discue/mongodb-resource-client

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discue/mongodb-resource-client - npm Package Compare versions

Comparing version 0.33.0 to 0.34.0

1

lib/aggregations.d.ts

@@ -45,2 +45,3 @@ export function EQUALS(field: string, target: unknown): any;

};
export function INDEX_STATS(): any;
export type LookupOptions = {

@@ -47,0 +48,0 @@ /**

@@ -398,2 +398,12 @@ 'use strict'

/**
*
* @returns {Object}
*/
module.exports.INDEX_STATS = () => {
return {
'$indexStats': {}
}
}
function withLeadingDollar(string) {

@@ -400,0 +410,0 @@ if (!string.startsWith('$')) {

8

lib/index.d.ts

@@ -1,12 +0,6 @@

export type SimpleResourceStorage = import('./simple-resource-storage.js');
export const SimpleResourceStorage: typeof import("./simple-resource-storage.js");
export type OneToFewRefStorage = import('./one-to-few-ref-storage.js');
export const OneToFewRefStorage: typeof import("./one-to-few-ref-storage.js");
export type OneToFewResourceStorage = import('./one-to-few-resource-storage.js');
export const OneToFewResourceStorage: typeof import("./one-to-few-resource-storage.js");
export type OneToManyResourceStorage = any;
export const OneToManyResourceStorage: any;
export type ResourceStorageHistory = import('./history.js');
export const OneToManyResourceStorage: typeof import("./one-to-many-resource-storage.js");
export const ResourceStorageHistory: typeof import("./history.js");
export type ResourceLock = import('./locks.js');
export const ResourceLock: typeof import("./locks.js");
'use strict'
/**
* @typedef {import('./simple-resource-storage.js')} SimpleResourceStorage
*/
module.exports.SimpleResourceStorage = require('./simple-resource-storage.js')
/**
* @typedef {import('./one-to-few-ref-storage.js')} OneToFewRefStorage
*/
module.exports.OneToFewRefStorage = require('./one-to-few-ref-storage.js')
/**
* @typedef {import('./one-to-few-resource-storage.js')} OneToFewResourceStorage
*/
module.exports.OneToFewResourceStorage = require('./one-to-few-resource-storage.js')
/**
* @typedef {import('./one-to-many-resource-storage.js')} OneToManyResourceStorage
*/
module.exports.OneToManyResourceStorage = require('./one-to-many-resource-storage.js')
/**
* @typedef {import('./history.js')} ResourceStorageHistory
*/
module.exports.ResourceStorageHistory = require('./history.js')
/**
* @typedef {import('./locks.js')} ResourceLock
*/
module.exports.ResourceLock = require('./locks.js')

@@ -44,3 +44,2 @@ 'use strict'

* @name GetOptions
* @private
* @typedef GetOptions

@@ -47,0 +46,0 @@ * @property {boolean} withMetadata true if also meta data should be returned

@@ -1,8 +0,6 @@

/// <reference types="node" />
export = exports;
declare class exports extends Base {
/**
*
* @public
* @param {ConstructorOptions} options
* @returns
*/

@@ -24,6 +22,6 @@ constructor(options: ConstructorOptions);

* @param {String|Array.<String>} resourceIds resource ids that will added to the resource path i.e. /users/${id}/documents/${id}
* @param {GetOptions} options
* @param {Object} options
* @returns {Object}
*/
get(resourceIds: string | Array<string>, options: GetOptions): any;
get(resourceIds: string | Array<string>, options: any): any;
/**

@@ -101,3 +99,58 @@ * @name FindOptions

}
declare namespace exports {
export { ConstructorOptions, GetOptions, MongoClient };
}
import Base = require("./simple-resource-storage.js");
import OneToFewStorage = require("./one-to-few-ref-storage.js");
type ConstructorOptions = {
/**
* configured mongo client to use. Can be null if url is set
*/
client: MongoClient;
/**
* name of the mongodb database
*/
databaseName?: string;
/**
* indexes to be created on instantiation. Use format {key:1} for single indexes and {key1: 1, key:2} for compound indexes
*/
indexes?: Array<any>;
/**
* name of the mongodb collection used to store the resources
*/
collectionName: string;
/**
* name of the resource e.g. users, customers, topics, shipments
*/
resourceName: string;
/**
* slash separated path describing the hierarchy e.g. universities/teachers/subjects/exams.
*/
resourcePath?: string;
/**
* slash separated path describing which path elements should not be returned to callers
*/
hiddenResourcePath?: string;
/**
* true if documents should also store references to their parents e.g. student have references to their schools
*/
enableTwoWayReferences: string;
/**
* if provided, will trigger events base on resource creation, updates and deletion
*/
eventEmitter: import('node:events').EventEmitter;
};
type GetOptions = {
/**
* true if also meta data should be returned
*/
withMetadata: boolean;
/**
* true if $path propety should be added to documents e.g. `$path=/countries/1/cities/2/companies`
*/
addDocumentPath: boolean;
/**
* MongoDB projection object e.g. { id: 0, name: 0 }
*/
projection: any;
};
type MongoClient = import('mongodb').MongoClient;

@@ -52,3 +52,2 @@ 'use strict'

* @name GetOptions
* @private
* @typedef GetOptions

@@ -106,5 +105,4 @@ * @property {boolean} withMetadata true if also meta data should be returned

/**
*
* @public
* @param {ConstructorOptions} options
* @returns
*/

@@ -163,3 +161,3 @@ constructor(options) {

* @param {String|Array.<String>} resourceIds resource ids that will added to the resource path i.e. /users/${id}/documents/${id}
* @param {GetOptions} options
* @param {Object} options
* @returns {Object}

@@ -166,0 +164,0 @@ */

@@ -261,3 +261,3 @@ export = exports;

/**
* indexes to be created on instantiation. Use format {key:1} for single indexes and {key1: 1, key:2} for compound indexes
* indexes to be created on instantiation. Use format {key:1} for single indexes and {key1: 1, key:2} for compound indexes. See https://www.mongodb.com/docs/manual/reference/command/createIndexes/#command-fields
*/

@@ -264,0 +264,0 @@ indexes?: Array<any>;

@@ -24,3 +24,3 @@ 'use strict'

* @property {string} collectionName name of the mongodb collection used to store the resources
* @property {Array.<Object>} [indexes=null] indexes to be created on instantiation. Use format {key:1} for single indexes and {key1: 1, key:2} for compound indexes
* @property {Array.<Object>} [indexes=null] indexes to be created on instantiation. Use format {key:1} for single indexes and {key1: 1, key:2} for compound indexes. See https://www.mongodb.com/docs/manual/reference/command/createIndexes/#command-fields
* @property {import('node:events').EventEmitter} eventEmitter if provided, will trigger events base on resource creation, updates and deletion

@@ -96,3 +96,9 @@ *

if (indexes?.length > 0) {
const indexSpecifications = indexes.map((index) => { return { key: index } })
const indexSpecifications = indexes.map((index) => {
if (index.key) {
return index
} else {
return { key: index }
}
})
await collection.createIndexes(indexSpecifications)

@@ -99,0 +105,0 @@ }

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.33.0",
"version": "0.34.0",
"description": "Simple wrapper around mongodb client allowing easier managing of resources",

@@ -57,16 +57,16 @@ "main": "lib/index",

"devDependencies": {
"@discue/open-telemetry-tracing": "^0.10.0",
"@discue/open-telemetry-tracing": "^0.13.0",
"@types/chai": "^4.3.14",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.2",
"@types/node": "^20.12.7",
"chai": "4",
"documentation": "^14.0.3",
"eslint": "^9.0.0",
"eslint": "^9.1.1",
"mocha": "^10.4.0",
"mongodb": "^6.5.0",
"mongodb-memory-server": "^9.1.8",
"mongodb-memory-server": "^9.2.0",
"nodemon": "^3.1.0",
"standard-version": "^9.5.0",
"typescript": "^5.4.3"
"typescript": "^5.4.5"
}
}
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