File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change 1
- import app from 'firebase/app' ;
1
+ import firebase from 'firebase/app' ;
2
+
2
3
import 'firebase/auth' ;
3
4
import 'firebase/firestore' ;
4
5
5
6
import firebaseConfig from '../../config/firebaseConfig' ;
6
7
7
8
class Firebase {
8
9
constructor ( ) {
9
- app . initializeApp ( firebaseConfig ) ;
10
+ firebase . initializeApp ( firebaseConfig ) ;
11
+
12
+ this . auth = firebase . auth ( ) ;
13
+ this . firestore = firebase . firestore ( ) ;
10
14
11
- this . auth = app . auth ( ) ;
12
- this . db = app . firestore ( ) ;
15
+ this . usersCollectionRef = this . firestore . collection ( 'users' ) ;
13
16
}
14
17
15
18
signUp = ( email , password ) =>
@@ -29,17 +32,9 @@ class Firebase {
29
32
30
33
updatePassword = password => this . auth . currentUser . updatePassword ( password ) ;
31
34
32
- addUser = ( uid , userData ) =>
33
- this . db
34
- . collection ( 'users' )
35
- . doc ( uid )
36
- . set ( userData ) ;
37
-
38
- getUser = uid =>
39
- this . db
40
- . collection ( 'users' )
41
- . doc ( uid )
42
- . get ( ) ;
35
+ addUser = ( uid , userData ) => this . usersCollectionRef . doc ( uid ) . set ( userData ) ;
36
+
37
+ getUser = uid => this . usersCollectionRef . doc ( uid ) . get ( ) ;
43
38
}
44
39
45
40
export default Firebase ;
You can’t perform that action at this time.
0 commit comments