import * as mongoose from "mongoose" ; import { Model } from "../Types" ; export abstract class DataAccessBase < T extends mongoose . Document > { private model : Model ; protected constructor ( model ) { this . model = model ; } Add ( item ) { return new Promise < boolean > ( ( callback , error ) => { this . model . create ( item , ( err , result ) => { if ( err ) { error ( err ) ; } callback ( ! result ) ; } ) ; } ) ; } GetAll ( conditions , fields ) { return new Promise < T [ ] > ( ( callback , error ) => { this . model . find ( conditions , fields , ( err , result ) => { if ( err ) { error ( err ) ; } if ( result ) { callback ( result ) ; } } ) ; } ) ; } }