import firebase from 'firebase/app' ; import 'firebase/firestore' ; import { FirestoreSimple } from '../src/' ; const app = firebase . initializeApp ( { projectId : 'example' } ) ; const firestore = firebase . firestore ( ) ; firestore . useEmulator ( 'localhost' , 8080 ) ; const ROOT_PATH = 'example/web_basic' ; interface User { id : string ; coin : number ; timestamp : Date ; } const main = async ( ) => { const firestoreSimple = new FirestoreSimple ( firestore ) ; const dao = firestoreSimple . collection < User > ( { path : `${ ROOT_PATH }/user` } ) ; const userId = await dao . add ( { coin : 100 , timestamp : firebase . firestore . FieldValue . serverTimestamp ( ) } ) ; console . log ( await dao . fetch ( userId ) ) ; await dao . update ( { id : userId , coin : firebase . firestore . FieldValue . increment ( 100 ) , timestamp : firebase . firestore . FieldValue . serverTimestamp ( ) } ) ; console . log ( await dao . fetch ( userId ) ) ; const docs = await dao . fetchAll ( ) ; await dao . bulkDelete ( docs . map ( ( doc ) => doc . id ) ) ; await app . delete ( ) ; } ; main ( ) ;