import { Firestore } from '@google-cloud/firestore' ; import Logger from 'js-logger' ; import { Provider , ProviderTypes } from '../lib/structures/Provider' ; export class FirestoreProvider extends Provider { client : Firestore ; type : ProviderTypes ; constructor ( options ? ) { super ( ) ; this . client = new Firestore ( options ) ; this . type = 'firestore' ; } async init ( ) { Logger . debug ( 'Firestore initializated!' ) ; this . emit ( 'connected' , this . client ) ; return ; } async insert ( documentName , value ) { const document = this . client . doc ( documentName ) ; const data = await document . set ( value ) ; return data ; } async get ( documentName ) { const document = this . client . doc ( documentName ) ; const data = await document . get ( ) ; return data ; } async update ( documentName , value ) { const document = this . client . doc ( documentName ) ; const data = await document . update ( value ) ; return data ; } async delete ( documentName ) { const document = this . client . doc ( documentName ) ; const data = await document . delete ( ) ; return data ; } }