Skip to content

Commit 79e8ecf

Browse files
committed
First cut at snippets for instrumenting RTDB and Firestore.
1 parent 8a72018 commit 79e8ecf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

database/emulator-suite.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
export async function onDocumentReady() {
4+
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+
}
11+
12+
var myApp = firebase.initializeApp(firebaseConfig);
13+
const db = myApp.database();
14+
// [END rtdb_emulator_connect]
15+
}

firestore/emulator-suite.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
export async function onDocumentReady(firebaseApp) {
4+
5+
//[START fs_emulator_connect]
6+
// firebasApp previously initialized using firebase.initializeApp()
7+
const db = firebaseApp.firestore();
8+
if (location.hostname === "localhost") {
9+
db.settings({
10+
host: "localhost:8081",
11+
ssl: false
12+
});
13+
}
14+
// [END fs_emulator_connect]
15+
}

0 commit comments

Comments
 (0)