import { iOutLet, MyAppDatabase } from '.'

export default class OutletDBService {
  static instance: OutletDBService
  outlet: Dexie.Table<iOutLet, number>
  static getInstance() {
    if (!OutletDBService.instance)
      OutletDBService.instance = new OutletDBService()
    return OutletDBService.instance
  }

  constructor() {
    const db = new MyAppDatabase()
    this.outlet = db.outlet
  }

  add(outlet: iOutLet) {
    return this.outlet.add(outlet)
  }

  update(outlet: iOutLet) {
    return this.outlet.update(outlet.id, outlet)
  }

  delete(id: number) {
    return this.outlet.delete(id)
  }

  get(id: number) {
    return this.outlet.get(id)
  }
}
