-
Notifications
You must be signed in to change notification settings - Fork 243
/
emulator-suite.js
23 lines (20 loc) · 725 Bytes
/
emulator-suite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// These samples are intended for Web so this import would normally be
// done in HTML however using modules here is more convenient for
// ensuring sample correctness offline.
import firebase from "firebase/app";
import "firebase/database";
function onDocumentReady() {
// [START rtdb_emulator_connect]
var db = firebase.database();
if (location.hostname === "localhost") {
// Point to the RTDB emulator running on localhost.
db.useEmulator("127.0.0.1", 9500);
}
// [END rtdb_emulator_connect]
}
function flushRealtimeDatabase() {
// [START rtdb_emulator_flush]
// With a database Reference, write null to clear the database.
firebase.database().ref().set(null);
// [END rtdb_emulator_flush]
}