mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
updates mongoose-paginate to work with new mongoose interfaces
This commit is contained in:
@@ -11,14 +11,15 @@ import {
|
||||
model,
|
||||
PaginateModel,
|
||||
PaginateOptions,
|
||||
PaginateResult
|
||||
PaginateResult,
|
||||
Document
|
||||
} from 'mongoose';
|
||||
import * as mongoosePaginate from 'mongoose-paginate';
|
||||
import { Router, Request, Response } from 'express';
|
||||
|
||||
|
||||
//#region Test Models
|
||||
interface User {
|
||||
interface User extends Document {
|
||||
email: string;
|
||||
username: string;
|
||||
password: string;
|
||||
@@ -32,8 +33,7 @@ const UserSchema: Schema = new Schema({
|
||||
|
||||
UserSchema.plugin(mongoosePaginate);
|
||||
|
||||
type UserModel<T> = _UserModel<T> & PaginateModel<T>;
|
||||
interface _UserModel<T> {}
|
||||
interface UserModel<T extends Document> extends PaginateModel<T> {};
|
||||
|
||||
let UserModel: UserModel<User> = model<User>('User', UserSchema) as UserModel<User>;
|
||||
//#endregion
|
||||
|
||||
+3
-4
@@ -26,16 +26,15 @@ declare module 'mongoose' {
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export type PaginateModel<T> = _PaginateModel<T> & Model<T>;
|
||||
interface _PaginateModel<T> {
|
||||
interface PaginateModel<T extends Document> extends Model<T> {
|
||||
paginate(query?: Object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult<T>) => void): Promise<PaginateResult<T>>;
|
||||
}
|
||||
|
||||
export function model<T extends Document, Statics>(
|
||||
export function model<T extends Document>(
|
||||
name: string,
|
||||
schema?: Schema,
|
||||
collection?: string,
|
||||
skipInit?: boolean): Statics & PaginateModel<T>;
|
||||
skipInit?: boolean): PaginateModel<T>;
|
||||
}
|
||||
|
||||
declare module 'mongoose-paginate' {
|
||||
|
||||
Reference in New Issue
Block a user