File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change 3
3
export async function onDocumentReady ( ) {
4
4
5
5
//[START rtdb_emulator_connect]
6
- let firebaseConfig = {
7
- // Point to the RTDB emulator running on localhost.
8
- // Here we supply database namespace 'foo'.
9
- databaseURL : "http://localhost:9000?ns=foo"
10
- }
6
+ if ( location . hostname === "localhost" ) {
11
7
12
- var myApp = firebase . initializeApp ( firebaseConfig ) ;
13
- const db = myApp . database ( ) ;
8
+ var firebaseConfig = {
9
+ // Point to the RTDB emulator running on localhost.
10
+ // In almost all cases the ns (namespace) is your project ID.
11
+ databaseURL : "http://localhost:9000?ns=YOUR_DATABASE_NAMESPACE"
12
+ }
13
+
14
+ var myApp = firebase . initializeApp ( firebaseConfig ) ;
15
+ var db = myApp . database ( ) ;
16
+ }
14
17
// [END rtdb_emulator_connect]
15
18
}
16
19
17
- export async function flushRealtimeDatabase ( anRTDBReference ) {
20
+ export async function flushRealtimeDatabas ( firebase ) {
18
21
19
22
//[START rtdb_emulator_flush]
20
- // With a database Reference, write null to the root node to delete the database.
21
- anRTDBReference . child ( "/" ) . set ( null ) ;
23
+ // With a database Reference, write null to clear the database.
24
+ firebase . database ( ) . ref ( ) . set ( null ) ;
22
25
// [END rtdb_emulator_connect]
23
26
}
You can’t perform that action at this time.
0 commit comments