Skip to content

Instantly share code, notes, and snippets.

@danahartweg
Created July 18, 2021 14:40
Show Gist options
  • Save danahartweg/64ce2aff04f5909e71e6d56d668627a6 to your computer and use it in GitHub Desktop.
Save danahartweg/64ce2aff04f5909e71e6d56d668627a6 to your computer and use it in GitHub Desktop.
Create user Cloud Function - Unit testing Cloud Firestore
import { auth } from 'firebase-functions';
import { getFirestore } from '../admin';
export const create = auth.user().onCreate(async (userRecord) => {
const db = getFirestore();
return db
.collection('users')
.doc(userRecord.uid)
.set({
displayName: userRecord.displayName ?? '',
email: userRecord.email ?? '',
homesteads: {},
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment