I'm trying to automatically create a user data in my firestore db when user sign up through firestore functions. However I got 2 option for sign up. Bussiness account and personal account. If user signup as bussiness then I want to add "usertype = 1" into my document and when personal then "usertype=2" I managed to automaticaly create a document on signup via functions
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
const db = admin.firestore()
exports.createUserData = functions.auth.user().onCreate((user) => {
const uid = user.uid
const email = user.email
const newUserRef = db.collection("user").doc(uid)
return newUserRef.set({
userId: uid,
email: email
})
});
But how I can I also pass "usertype" into that function? Or which function to use to do that?