File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ function onDocumentReady ( ) {
3+
4+ //[START rtdb_emulator_connect]
5+ if ( location . hostname === "localhost" ) {
6+
7+ var firebaseConfig = {
8+ // Point to the RTDB emulator running on localhost.
9+ // In almost all cases the ns (namespace) is your project ID.
10+ databaseURL : "http://localhost:9000?ns=YOUR_DATABASE_NAMESPACE"
11+ }
12+
13+ var myApp = firebase . initializeApp ( firebaseConfig ) ;
14+ var db = myApp . database ( ) ;
15+ }
16+ // [END rtdb_emulator_connect]
17+ }
18+
19+ function flushRealtimeDatabase ( firebase ) {
20+
21+ //[START rtdb_emulator_flush]
22+ // With a database Reference, write null to clear the database.
23+ firebase . database ( ) . ref ( ) . set ( null ) ;
24+ // [END rtdb_emulator_connect]
25+ }
Original file line number Diff line number Diff line change 1+
2+ export async function onDocumentReady ( firebaseApp ) {
3+
4+ //[START fs_emulator_connect]
5+ // firebaseApp previously initialized using firebase.initializeApp().
6+ var db = firebaseApp . firestore ( ) ;
7+ if ( location . hostname === "localhost" ) {
8+ // Note that the Firebase Web SDK must connect to the WebChannel port
9+ db . settings ( {
10+ host : "localhost:8081" ,
11+ ssl : false
12+ } ) ;
13+ }
14+ // [END fs_emulator_connect]
15+ }
You can’t perform that action at this time.
0 commit comments