import { firestore } from 'firebase-admin' ; import { FirebaseAdmin , WriteResult } from '../client/firebase-admin' ; export interface ProjectInput { projectUid : string ; increase ? : boolean ; } export const updateViews = async ( projectUid ) : Promise < WriteResult > => { return FirebaseAdmin . firestore ( ) . collection ( 'projects' ) . doc ( projectUid ) . set ( { views : firestore . FieldValue . increment ( 1 ) , } , { merge : true } ) ; } ; export const updateFollowers = async ( projectUid , increase ) : Promise < WriteResult > => { return FirebaseAdmin . firestore ( ) . collection ( 'projects' ) . doc ( projectUid ) . set ( { followers : increase ? firestore . FieldValue . increment ( 1 ) : firestore . FieldValue . increment ( - 1 ) , } , { merge : true } ) ; } ;