-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing MongoPaging results in declaration file for module error #332
Comments
Custom.d.tsdeclare module "mongo-cursor-pagination" {
type PaginatedPluginFn = (schema: any, options: any) => void;
const mongoosePlugin: PaginatedPluginFn;
export { mongoosePlugin };
}
declare module "mongoose" {
type ModelKeys<T> = Exclude<keyof T, keyof Omit<Document, "_id">>;
interface PaginateResult<T> {
results: T[];
next?: string;
previous?: string;
hasNext?: boolean;
hasPrevious?: boolean;
}
interface PaginateModel<T, TQueryHelpers = {}, TMethods = {}>
extends Model<T, TQueryHelpers, TMethods> {
/*
@param {Object} params
-query {Object} The find query.
-limit {Number} The page size. Must be between 1 and `config.MAX_LIMIT`.
-fields {Object} Fields to query in the Mongo object format, e.g. {_id: 1, timestamp :1}.
The default is to query all fields.
-paginatedField {String} The field name to query the range for. The field must be:
1. Orderable. We must sort by this value. If duplicate values for paginatedField field
exist, the results will be secondarily ordered by the _id.
2. Indexed. For large collections, this should be indexed for query performance.
3. Immutable. If the value changes between paged queries, it could appear twice.
4. Consistent. All values (except undefined and null values) must be of the same type.
The default is to use the Mongo built-in '_id' field, which satisfies the above criteria.
The only reason to NOT use the Mongo _id field is if you chose to implement your own ids.
-sortAscending {Boolean} True to sort using paginatedField ascending (default is false - descending).
-sortCaseInsensitive {boolean} Whether to ignore case when sorting, in which case `paginatedField`
must be a string property.
-next {String} The value to start querying the page.
-previous {String} The value to start querying previous page.
*/
paginate(param: {
query?: FilterQuery<T>;
limit?: number;
fields?: Record<ModelKeys<T>, 0 | 1>;
paginatedField?: ModelKeys<T>;
sortAscending?: boolean;
sortCaseInsensitive?: boolean;
next?: string;
previous?: string;
}): Promise<PaginateResult<T>>;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just started using this awesome package for my Angular project (TypeScript based).
I've noticed that the import statement result in an error as shown below in the screenshot.
How can I resolve this please?
The text was updated successfully, but these errors were encountered: