import { PlainObject } from 'egg' ; import DB from './base' ; import Condition from '../condition' ; export default class Collection { private db : DB ; private name : string ; constructor ( db , name ) { this . db = db ; this . name = name ; } public get ( ) { return this . db . get ( this . name ) ; } public query ( json ) { return this . db . query ( this . name , json ) ; } public add ( json ) { return this . db . add ( this . name , json ) ; } public update ( where , json ) { return this . db . update ( this . name , where , json ) ; } public delete ( field ) { return this . db . delete ( this . name , field ) ; } public getPager ( condition ) { return this . db . getPager ( this . name , condition ) ; } public getOrderAscByField ( field ) { return this . get ( ) . orderBy ( field , 'asc' ) . value ( ) ; } public getOrderDescByField ( field ) { return this . get ( ) . orderBy ( field , 'desc' ) . value ( ) ; } }