Skip to content

Commit 0f88e0e

Browse files
committed
Doctor up flush argument.
1 parent 79981d4 commit 0f88e0e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

database/emulator-suite.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@
33
export async function onDocumentReady() {
44

55
//[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") {
117

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+
}
1417
// [END rtdb_emulator_connect]
1518
}
1619

17-
export async function flushRealtimeDatabase(anRTDBReference) {
20+
export async function flushRealtimeDatabas(firebase) {
1821

1922
//[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);
2225
// [END rtdb_emulator_connect]
2326
}

0 commit comments

Comments
 (0)