updates mongoose-paginate to work with new mongoose interfaces

This commit is contained in:
Simon
2016-08-21 15:49:27 -04:00
parent 2854c554b2
commit 3f9a9295bf
2 changed files with 7 additions and 8 deletions
+4 -4
View File
@@ -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
View File
@@ -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' {