MCPcopy Create free account
hub / github.com/WardAnalytics/WardGraph / createUserInDatabase

Function createUserInDatabase

src/services/firestore/user/user.ts:17–32  ·  view source on GitHub ↗
(user: User)

Source from the content-addressed store, hash-verified

15 * @param user - The user to be created in the database
16 */
17export const createUserInDatabase = async (user: User) => {
18 // Checks if user exists in the database
19 const userRef = doc(db, USERS_COLLECTION, user.uid);
20 const docRef = await getDoc(userRef);
21
22 // If the user exists, return
23 if (docRef.exists()) return;
24
25 // Saves the user in the firestore database
26 const newUser: UserDB = {
27 email: user.email!,
28 name: user.displayName,
29 };
30
31 await setDoc(doc(db, USERS_COLLECTION, user.uid), newUser);
32};

Callers 2

loginFunction · 0.90
signUpWithGoogleFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected