@linkedmink/multilevel-aging-cache-mongoose
Version:
Package implements Mongoose for @linkedmink/multilevel-aging-cache
34 lines • 1.46 kB
TypeScript
import { Document, FilterQuery, Types } from 'mongoose';
export declare type ToNumberFunc = <T>(age: T) => number;
export declare type ToTypeFunc = <T>(value: number) => T;
export declare type FilterQueryFunc<TKey, TValue extends Document> = (key: TKey) => FilterQuery<TValue>;
/**
* Options to configure Mongoose (mongodb) as a storage provider
*/
export interface IMongooseProviderOptions<TKey = Types.ObjectId, TValue extends Document = Document> {
/**
* A function that returns a query to the search key
*/
keyFunc?: FilterQueryFunc<TKey, TValue>;
/**
* The property (with . seperators for nested properties) to use as the search key on a document
*/
keyProperty?: string;
/**
* The property (with . seperators for nested properties) that stores when the the document was last modified
*/
ageProperty: string;
/**
* Convert the ageProperty to a numeric age. Set undefined if already a number
*/
ageToNumberFunc?: ToNumberFunc;
/**
* Convert the numeric age to the ageProperty type. Set undefined if already a number
*/
numberToAgeFunc?: ToTypeFunc;
}
/**
* Default options to use Mongoosedb _id ObjectID as the key and update as a write policy
*/
export declare function getDefaultOptions<TValue extends Document = Document>(): IMongooseProviderOptions<Types.ObjectId, TValue>;
//# sourceMappingURL=IMongooseProviderOptions.d.ts.map