Creating User by Email in Firestore (Raw Mode) Using Admin SDK

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;
  }
}

Hi @milk :wave: Welcome to the community

I'll preface by saying I haven't done a ton of work with Firestore raw queries, so there could be other solutions, but one option is to have some of your logic a Javascript query and then use .trigger() and additionalScope to pass data from the JS query to your Firestore raw query. See this simplified example where I'm passing the user info to Firestore: