I'm getting "FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore" when I try to initiate a stream or fetch.
I'm using Firebase 9, with the fancy imports. Basically copy and pasted the mangetar setup from the docs. FIrestore is working fine, I can access it and pull docs down.
// ---------------------------------------------
// 0. Initialise firebase
// ---------------------------------------------
import Vue from 'vue';
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, doc } from 'firebase/firestore';
// const firebaseApp = initializeApp({ /* pass your config... */ })
const config = {
//
};
const firebaseApp = initializeApp(config);
const db = getFirestore();
/**
* A helper function that generates a random Firestore ID
*/
function generateRandomId() {
return doc(collection(db, 'random')).id;
}
// ---------------------------------------------
// 1. the plugin firestore for remote data store
// ---------------------------------------------
import { CreatePlugin as PluginFirestore } from '@magnetarjs/plugin-firestore';
// create the remote store plugin instance & pass your `db`:
const remote = PluginFirestore({ db });
// ---------------------------------------
// 2. the plugin vue2 for local data store
// ---------------------------------------
import { CreatePlugin as PluginVue } from '@magnetarjs/plugin-vue2';
// create the local store plugin instance & pass your `generateRandomId`:
const local = PluginVue({ vueInstance: Vue, generateRandomId });
// -----------------------------------------------------
// 3. instantiate the Magnetar instance with the store plugins
// -----------------------------------------------------
import { Magnetar } from 'magnetar';
import { logger } from '@magnetarjs/utils';
export const magnetar = Magnetar({
stores: { local, remote },
localStoreName: 'local',
executionOrder: {
read: ['local', 'remote'],
write: ['local', 'remote'],
delete: ['local', 'remote']
},
on: { success: logger } // disable this on production builds
});