@discue/mongodb-resource-client
Advanced tools
Comparing version 0.39.0 to 0.40.0
@@ -21,14 +21,4 @@ export function EQUALS(field: string, target: unknown): any; | ||
export function APPEND_OBJECTS(...expressions: any[]): any; | ||
export function LET({ vars, inExpression }: LetOptions): { | ||
$let: { | ||
vars: any; | ||
in: any; | ||
}; | ||
}; | ||
export function TO_OBJECT({ key, value }: ToObjectOptions): { | ||
$arrayToObject: { | ||
k: string; | ||
v: any; | ||
}[][]; | ||
}; | ||
export function LET({ vars, inExpression }: LetOptions): any; | ||
export function TO_OBJECT({ key, value }: ToObjectOptions): any; | ||
export function CONCAT_STRINGS(...strings: any[]): any; | ||
@@ -39,9 +29,5 @@ export function JOIN_STRINGS(separator: string, ...strings: any[]): any; | ||
export function AS_ROOT(fieldName: string): any; | ||
export function EXISTS(fieldName: string): { | ||
$match: { | ||
[x: string]: { | ||
$exists: boolean; | ||
}; | ||
}; | ||
}; | ||
export function EXISTS(fieldName: string): any; | ||
export function TO_LONG(fieldname: string): object; | ||
export function DATE_TRUNC(fieldname: string, { unit, timezone, binSize, startOfWeek }: string): any; | ||
export function INDEX_STATS(): any; | ||
@@ -48,0 +34,0 @@ export type LookupOptions = { |
@@ -290,3 +290,3 @@ 'use strict' | ||
* @param {LetOptions} options | ||
* @returns | ||
* @returns {Object} | ||
*/ | ||
@@ -310,3 +310,3 @@ module.exports.LET = ({ vars, inExpression }) => { | ||
* @param {ToObjectOptions} options | ||
* @returns | ||
* @returns {Object} | ||
*/ | ||
@@ -392,3 +392,3 @@ module.exports.TO_OBJECT = ({ key = '$$this', value }) => { | ||
* @param {String} fieldName the field to check for existence | ||
* @returns | ||
* @returns {Object} | ||
*/ | ||
@@ -403,4 +403,39 @@ module.exports.EXISTS = (fieldName) => { | ||
* | ||
* @param {string} fieldname | ||
* @returns {object} | ||
*/ | ||
module.exports.TO_LONG = (fieldname) => { | ||
return { | ||
$set: { | ||
[fieldname]: { | ||
$toLong: withLeadingDollar(fieldname) | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* | ||
* @param {string} fieldname | ||
* @param {string} options | ||
* @param {string} unit e.g. day, month, quarter, year. | ||
* @param {number} [binSize=1] specifies the amount units | ||
* @param {string} [timezone=Europe/Berlin] | ||
* @param {string} [startOfWeek=monday] | ||
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/ | ||
* @returns {Object} | ||
*/ | ||
module.exports.DATE_TRUNC = (fieldname, { unit, timezone = 'Europe/Berlin', binSize = 1, startOfWeek = 'monday' }) => { | ||
return { | ||
$dateTrunc: { | ||
date: withLeadingDollar(fieldname), | ||
unit, timezone, binSize, startOfWeek | ||
} | ||
} | ||
} | ||
/** | ||
* | ||
* @returns {Object} | ||
*/ | ||
module.exports.INDEX_STATS = () => { | ||
@@ -412,2 +447,7 @@ return { | ||
/** | ||
* | ||
* @param {string} string | ||
* @returns {string} | ||
*/ | ||
function withLeadingDollar(string) { | ||
@@ -414,0 +454,0 @@ if (!string.startsWith('$')) { |
@@ -17,3 +17,3 @@ export = exports; | ||
*/ | ||
protected _getConnectedClient(): import('mongodb').MongoClient; | ||
protected _getConnectedClient(): import("mongodb").MongoClient; | ||
/** | ||
@@ -24,3 +24,3 @@ * @protected | ||
*/ | ||
protected _getDb(givenClient?: import('mongodb').MongoClient): import('mongodb').Db; | ||
protected _getDb(givenClient?: import("mongodb").MongoClient): import("mongodb").Db; | ||
/** | ||
@@ -32,3 +32,3 @@ * @protected | ||
*/ | ||
protected _getCollection(collectionName?: import('mongodb').MongoClient, givenClient?: import('mongodb').MongoClient): Promise<Collection>; | ||
protected _getCollection(collectionName?: import("mongodb").MongoClient, givenClient?: import("mongodb").MongoClient): Promise<Collection>; | ||
/** | ||
@@ -102,5 +102,5 @@ * @protected | ||
type WithMongoClient = { | ||
client: import('mongodb').MongoClient; | ||
client: import("mongodb").MongoClient; | ||
}; | ||
type Collection = import('mongodb').Collection; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type Collection = import("mongodb").Collection; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -7,3 +7,3 @@ export = exports; | ||
*/ | ||
constructor({ client, databaseName, collectionName, connectTimeout, usageEventPrefix, eventEmitter }?: any); | ||
constructor({ client, databaseName, collectionName, connectTimeout, usageEventPrefix, eventEmitter }?: ConstructorOptions); | ||
_eventEmitter: any; | ||
@@ -10,0 +10,0 @@ _collectionName: any; |
@@ -26,3 +26,3 @@ export = exports; | ||
*/ | ||
create(resourceIds: string | Array<string>, ref: any, options?: import('mongodb').UpdateOptions | WithMongoClient): Promise<ObjectId>; | ||
create(resourceIds: string | Array<string>, ref: any, options?: import("mongodb").UpdateOptions | WithMongoClient): Promise<ObjectId>; | ||
/** | ||
@@ -45,3 +45,3 @@ * Delete a reference | ||
*/ | ||
delete(resourceIds: string | Array<string>, options?: import('mongodb').FindOneAndUpdateOptions | WithMongoClient): Promise<void>; | ||
delete(resourceIds: string | Array<string>, options?: import("mongodb").FindOneAndUpdateOptions | WithMongoClient): Promise<void>; | ||
} | ||
@@ -70,3 +70,3 @@ declare namespace exports { | ||
}; | ||
type ObjectId = import('mongodb').ObjectId; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type ObjectId = import("mongodb").ObjectId; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -82,3 +82,3 @@ export = exports; | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
eventEmitter: import("node:events").EventEmitter; | ||
}; | ||
@@ -95,2 +95,2 @@ type GetOptions = { | ||
}; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -147,3 +147,3 @@ export = exports; | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
eventEmitter: import("node:events").EventEmitter; | ||
}; | ||
@@ -164,2 +164,2 @@ type GetOptions = { | ||
}; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -1,2 +0,2 @@ | ||
export function toArrayAndClose(cursor: import('mongodb').AbstractCursor): Promise<any>; | ||
export function getFirstAndClose(cursor: import('mongodb').AbstractCursor): Promise<any>; | ||
export function toArrayAndClose(cursor: import("mongodb").AbstractCursor): Promise<any>; | ||
export function getFirstAndClose(cursor: import("mongodb").AbstractCursor): Promise<any>; |
@@ -17,3 +17,3 @@ export = exports; | ||
*/ | ||
enableEventing(eventEmitter: import('node:events').EventEmitter): void; | ||
enableEventing(eventEmitter: import("node:events").EventEmitter): void; | ||
/** | ||
@@ -159,3 +159,3 @@ * | ||
*/ | ||
create(resourceIds: string | Array<string>, resource: any, options?: import('mongodb').InsertOneOptions): Promise<any>; | ||
create(resourceIds: string | Array<string>, resource: any, options?: import("mongodb").InsertOneOptions): Promise<any>; | ||
/** | ||
@@ -229,3 +229,3 @@ * @typedef UpdateOptions | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
eventEmitter: import("node:events").EventEmitter; | ||
}; | ||
@@ -243,5 +243,5 @@ type GetOptions = { | ||
type WithMongoClient = { | ||
client: import('mongodb').MongoClient; | ||
client: import("mongodb").MongoClient; | ||
}; | ||
type Collection = import('mongodb').Collection; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type Collection = import("mongodb").Collection; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -35,3 +35,3 @@ export = exports; | ||
*/ | ||
create(resource: any, options?: import('mongodb').InsertOneOptions): Promise<any>; | ||
create(resource: any, options?: import("mongodb").InsertOneOptions): Promise<any>; | ||
} | ||
@@ -62,3 +62,3 @@ declare namespace exports { | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
eventEmitter: import("node:events").EventEmitter; | ||
}; | ||
@@ -75,3 +75,3 @@ type GetOptions = { | ||
}; | ||
type Collection = import('mongodb').Collection; | ||
type MongoClient = import('mongodb').MongoClient; | ||
type Collection = import("mongodb").Collection; | ||
type MongoClient = import("mongodb").MongoClient; |
@@ -1,2 +0,2 @@ | ||
declare function _exports(eventPrefix: any, collectionName: any, eventEmitter: import('node:events').EventEmitter): ({ context, resourceIds, before, after }: { | ||
declare function _exports(eventPrefix: any, collectionName: any, eventEmitter: import("node:events").EventEmitter): ({ context, resourceIds, before, after }: { | ||
context: any; | ||
@@ -3,0 +3,0 @@ resourceIds: any; |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.39.0", | ||
"version": "0.40.0", | ||
"description": "Simple wrapper around mongodb client allowing easier managing of resources", | ||
@@ -57,14 +57,14 @@ "main": "lib/index", | ||
"devDependencies": { | ||
"@discue/open-telemetry-tracing": "^0.13.0", | ||
"@discue/open-telemetry-tracing": "^1.0.0", | ||
"@types/chai": "^4.3.14", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^20.14.2", | ||
"@types/mocha": "^10.0.7", | ||
"@types/node": "^20.14.10", | ||
"chai": "4", | ||
"documentation": "^14.0.3", | ||
"eslint": "^9.5.0", | ||
"mocha": "^10.4.0", | ||
"mongodb": "^6.7.0", | ||
"eslint": "^9.6.0", | ||
"mocha": "^10.6.0", | ||
"mongodb": "^6.8.0", | ||
"standard-version": "^9.5.0", | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.5.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139902
3530