Using Realtime DB and Firestore Refs together
See original GitHub issueHi,
I’m trying to use both Firestore and RealtimeDB refs in my app simulataneously.
However when I initialise my Firebase Refs in the Firestore object on the Vue component I get an error.
export default {
name: 'Summary',
firestore:function(){
return {
posts: Firebase.firestore.collection('posts'),
users: Firebase.realtimedb.ref('/users')
}
},
}
The error:
vuefire.esm.js?bbf5:334 Uncaught (in promise) TypeError: document.onSnapshot is not a function
at bindDocument (vuefire.esm.js?bbf5:334)
at eval (vuefire.esm.js?bbf5:371)
at new Promise (<anonymous>)
at bind (vuefire.esm.js?bbf5:360)
at VueComponent.Vue.$bind (vuefire.esm.js?bbf5:420)
at eval (vuefire.esm.js?bbf5:400)
at Array.forEach (<anonymous>)
at VueComponent.created (vuefire.esm.js?bbf5:399)
at callHook (vue.esm.js?65d7:2921)
at VueComponent.Vue._init (vue.esm.js?65d7:4630)
I also tried manually binding the refs in the vue component created() function like so:
created() {
this.$bind('users', Firebase.realtimedb.ref('/users'))
}
Which results in the same error.
Am I doing something wrong? I’m just replicating the setup I had before using the Firestore branch of VueFire and beginning the migration of some of my Realtime DB calls.
Thanks
FYI if the naming of my Firebase objects is confusing. This is how my Firebase object is initialised:
import _firebase from 'firebase'
let config = {
...{{PROJECT SPECIFIC CONFIG}}
};
let settings = {timestampsInSnapshots: true};
let app = _firebase.initializeApp(config)
let realtimedb = app.database();
let firestore = app.firestore();
firestore.settings(settings)
var _signOut = function() {
app.auth().signOut().then(function() {
// Sign-out successful.
}).catch(function(error) {
// An error happened.
});
}
export const Firebase = {
app: app,
realtimedb: realtimedb,
firestore: firestore,
instance: _firebase,
signOut:_signOut
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Sync Firestore with Realtime database [closed] - Stack Overflow
You just need to create a Cloud Function that watches for changes in the Realtime Database and writes those changes to Firestore.
Read more >Querying and filtering data | Firestore - Google Cloud
Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.
Read more >Fetch All Data from Firebase Realtime DB v9 in TABLE using ...
retreive firebase 9 data in bootstrap html table using reactreact bootstap table firebase database v9get data from firebase realtime ...
Read more >Realtime Database - React Native Firebase
The Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. React Native Firebase ......
Read more >Using Firebase - Expo Documentation
You can consider using the Firebase JS SDK when you: Want to use Firebase services such as Authentication, Firestore, Realtime Database, and Storage...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added RTDB support for vuefire and still need to add it to vuexfire. I will like to get others opinion on API. Currently my plans (some are already done) are
default
export from Vuefire tofirestorePlugin
rtdbPlugin
for the RTDB$bind
for Firestore but make it configurable with options when installingfirestorePlugin
$rtdbBind
for RTDB but make it configurable with options when installingrtdbPlugin
$unbind
/$rtdbUnbind
. _The reasoning behind this is: I want to make it simpler by default for Firestore users as that database is more likely to be used$firebaseRefs
/$firestoreRefs
This makes it possible to use only a fraction of Vuefire/Vuexfire as well as use them both:
Thanks for quick response. I didn’t find the docs clear in this regard. Will work to figure it out now 👍