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
This commit is contained in:
obeliskos
2018-02-18 04:53:13 -05:00
parent e5c1512ab6
commit f124da6d40
+48 -4
View File
@@ -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<E extends object> {
* 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<SimplesortOptions>): this;
/**
* Allows sorting a resultset based on multiple columns.
@@ -1105,10 +1121,14 @@ declare class DynamicView<E extends object> 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<SimplesortOptions>): 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<E extends object> 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<CheckIndexOptions>): 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<CheckIndexOptions>): boolean;
public getSequencedIndexValues(property: string): string;