import admin from 'firebase-admin' ; import { FirestoreSimple } from '../src' ; process . env . GCLOUD_PROJECT = 'firestore-simple-test' ; process . env . FIRESTORE_EMULATOR_HOST = 'localhost:8080' ; admin . initializeApp ( { } ) ; const firestore = admin . firestore ( ) ; const ROOT_PATH = 'example/admin_field_value' ; 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 : admin . firestore . FieldValue . serverTimestamp ( ) } ) ; console . log ( await dao . fetch ( userId ) ) ; await dao . update ( { id : userId , coin : admin . firestore . FieldValue . increment ( 100 ) , timestamp : admin . firestore . FieldValue . serverTimestamp ( ) } ) ; console . log ( await dao . fetch ( userId ) ) ; const docs = await dao . fetchAll ( ) ; await dao . bulkDelete ( docs . map ( ( doc ) => doc . id ) ) ; } ; main ( ) ;