import mongoose from 'mongoose' declare interface RestOptions { idKey?: string idType?: string hint?: string maxAmount?: number fields: string | object populates: string[] | object[] model: mongoose.Document } declare type ListOptions = { page?: number limit?: number sort?: string } declare type ListResult = { list: object[], pagination: { page: number limit: number total?: number } } declare class RestService { /** * 由 filter 字符串构建 query * @param filter query filter string * @param params request params object */ static buildFilterQuery (filter: string, params?: object): object /** * pattern for 'key[value]' */ static KV_REGEXP: RegExp constructor (opts: RestOptions); name: string /** * 创建对象 */ create (data: object, query?: object): Promise /** * 查询列表 */ list (opts: ListOptions, query?: object): Promise /** * 搜索列表 */ search (fields: string[], keyword: string, opts: ListOptions, query?: object): Promise /** * 单体查询 */ fetch (id: any, query?: object): Promise /** * 单体修改 */ patch (id: any, data: object, query?: object): Promise /** * 单体删除 */ del (id: any, query?: object): Promise } export = RestService;