Last active
January 6, 2019 13:56
-
-
Save krizzu/76e15c471f258c66a82fef5135677d44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import firebase from 'react-native-firebase'; | |
export const DB = firebase.firestore(); | |
export const USER_COLLECTION = 'users'; // name of collection in Firestore | |
export async function createUserDataBaseEntry(userId: string) { | |
// creating a new transaction | |
return DB.runTransaction(async transaction => { | |
// get reference to 'users' collection, pointing to document with name of user's ID | |
const userDoc = DB.collection(USER_COLLECTION).doc(userId); | |
// create empty user | |
transaction.set(userDoc, { | |
name: null, | |
surname: null, | |
}); | |
}).catch(e => alert('Something went wrong:', e.message)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment