1.0.1 • Published 2 years ago

express-mongoose-paginate v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

express-mongoose-paginate

mongoose 分页插件

安装

npm install express-mongoose-paginate

使用

import type { Schema, model } from 'mongoose'
import {
  PaginationModel,
  mongoosePagination
} from 'express-mongoose-paginate'

type IArticle = {
  title: string
  content: string
}

const articleSchema = new Schema(
  {
    title: { type: String },
    content: { type: String }
  }
)

articleSchema.plugin(mongoosePagination)

const Article: PaginationModel<IArticle> = model<
  IArticle,
  PaginationModel<IArticle>
>('Article', articleSchema)

Article.paginate()