From f124da6d407e5be653d4725510fea94c60e80e2e Mon Sep 17 00:00:00 2001 From: obeliskos Date: Sun, 18 Feb 2018 04:53:13 -0500 Subject: [PATCH 1/2] updated typings to support new ops and updated interfaces - added new js compare ops ($jgt, $jgte, $jlt, $jlte, $jbetween) - simple interface updated to multipurpose isDesc property with options object - updated DynamicView.applySimplesort to use same SimplesortOptions interface - added collection.checkAllIndexes along with 'CheckIndexOptions' interface - added collection.checkIndex using same 'CheckIndexOptions' interface --- types/lokijs/index.d.ts | 52 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/types/lokijs/index.d.ts b/types/lokijs/index.d.ts index ca6903fa33..f9311c8ce1 100644 --- a/types/lokijs/index.d.ts +++ b/types/lokijs/index.d.ts @@ -30,6 +30,11 @@ declare var LokiOps: { $lte(a: any, b: any): boolean; /** ex : coll.find({'orderCount': {$between: [10, 50]}}); */ $between(a: any, vals: any/*[any, any]*/): boolean; + $jgt(a: any, b: any): boolean; + $jgte(a: any, b: any): boolean; + $jlt(a: any, b: any): boolean; + $jlte(a: any, b: any): boolean; + $jbetween(a: any, vals: any/*[any, any]*/): boolean; $in(a: any, b: any): boolean; $nin(a: any, b: any): boolean; $keyin(a: any, b: any): boolean; @@ -774,6 +779,13 @@ interface GetDataOptions { } +interface SimplesortOptions { + desc: boolean; + disableIndexIntersect: boolean; + forceIndexIntersect: boolean; + useJavascriptSorting: boolean; +} + /** * Resultset class allowing chainable queries. Intended to be instanced internally. * Collection.find(), Collection.where(), and Collection.chain() instantiate this. @@ -864,10 +876,14 @@ declare class Resultset { * Sorting based on the same lt/gt helper functions used for binary indices. * * @param propname - name of property to sort by. - * @param isdesc - (Optional) If true, the property will be sorted in descending order + * @param options - boolean to specify if sort is descending, or options object + * @param [options.desc] - whether to sort descending + * @param [options.disableIndexIntersect] - whether we should explicity not use array intersection. + * @param [options.forceIndexIntersect] - force array intersection (if binary index exists). + * @param [options.useJavascriptSorting] - whether results are sorted via basic javascript sort. * @returns Reference to this resultset, sorted, for future chain operations. */ - public simplesort(propname: keyof E, isdesc?: boolean): this; + public simplesort(propname: keyof E, options?: boolean | Partial): this; /** * Allows sorting a resultset based on multiple columns. @@ -1105,10 +1121,14 @@ declare class DynamicView extends LokiEventEmitter { * dv.applySimpleSort("name"); * * @param propname - Name of property by which to sort. - * @param [isdesc] - (Optional) If true, the sort will be in descending order. + * @param [options] - boolean for sort descending or options object + * @param [options.desc] - whether we should sort descending. + * @param [options.disableIndexIntersect] - whether we should explicity not use array intersection. + * @param [options.forceIndexIntersect] - force array intersection (if binary index exists). + * @param [options.useJavascriptSorting] - whether results are sorted via basic javascript sort. * @returns this DynamicView object, for further chain ops. */ - public applySimpleSort(propname: keyof E, isdesc?: boolean): this; + public applySimpleSort(propname: keyof E, options?: boolean | Partial): this; /** * applySortCriteria() - Allows sorting a resultset based on multiple columns. @@ -1302,6 +1322,11 @@ interface CollectionChange { obj: any; } +interface CheckIndexOptions { + randomSampling: boolean; + randomSamplingFactor: number; + repair: boolean; +} /** * Collection class that handles documents of same type @@ -1450,6 +1475,25 @@ declare class Collection extends LokiEventEmitter { * @param [force] - (Optional) flag indicating whether to construct index immediately */ public ensureIndex(property: keyof E, force?: boolean): void; + + /** + * Perform checks to determine validity/consistency of all binary indices + * @param [options] - optional configuration object + * @param [options.randomSampling] - whether (faster) random sampling should be used + * @param [options.randomSamplingFactor] - percentage of total rows to randomly sample + * @param [options.repair] - whether to fix problems if they are encountered + */ + public checkAllIndexes(options?: Partial): string[]; + + /** + * Perform checks to determine validity/consistency of a binary index + * @param property - name of the binary-indexed property to check + * @param [options] optional configuration object + * @param [options.randomSampling] - whether (faster) random sampling should be used + * @param [options.randomSamplingFactor] - percentage of total rows to randomly sample + * @param [options.repair] - whether to fix problems if they are encountered + */ + public checkIndex(property: keyof E, options?: Partial): boolean; public getSequencedIndexValues(property: string): string; From 60bb4e0774b8145e9b05fe97a768fba509d05b86 Mon Sep 17 00:00:00 2001 From: obeliskos Date: Sun, 18 Feb 2018 05:00:38 -0500 Subject: [PATCH 2/2] updated version --- types/lokijs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lokijs/index.d.ts b/types/lokijs/index.d.ts index f9311c8ce1..308cbb4842 100644 --- a/types/lokijs/index.d.ts +++ b/types/lokijs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for lokijs v1.5.1 +// Type definitions for lokijs v1.5.3 // Project: https://github.com/techfort/LokiJS // Definitions by: TeamworkGuy2 // Thomas Conner