I'm trying to bulk create a users by email in Firestore using the Admin SDK in Raw Mode. I can not find the correct syntax to access the Admin SDK.
I see the examples for "db.firestore().batch();".
I want to do something like this.
async function getOrCreateUser(email, password) {
try {
const userRecord = await auth.getUserByEmail(email);
userRecord.existingUser = true;
return userRecord;
} catch (error) {
if (error.code === "auth/user-not-found") {
await auth.createUser({
email,
password,
});
var userRecord = await auth.getUserByEmail(email);
userRecord.existingUser = false;
return userRecord;
}
if (error.code === "auth/email-already-exists") {
throw new Error("Invalid email");
}
throw error;
}
}