Я пытаюсь создать сценарий сервера (облачных функций), в котором определенные ключи извлекаются с помощью geofire и geoquery.
Я не знаю почему, но я получаю эту ошибку:
firebaseRef must be an instance of Firebase
at new GeoQuery (/srv/node_modules/geofire/dist/index.cjs.js:505:19)
at new GeoFire.query (/srv/node_modules/geofire/dist/index.cjs.js:1072:16)
at exports.sendNotification.functions.database.ref.onWrite (/srv/index.js:43:22)
at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:131:23)
at /worker/worker.js:825:24
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
мой код ниже:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const GeoFire = require('geofire');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('MyData/').onWrite((change,context) => {
const Locations = change.after.val(); //getting locations from triggering device
const geofire = new GeoFire.GeoFire(admin.database().ref('/geofire'));
const geoQuery = new geofire.query({ // <<=== giving error here in the Firebase Logs not while deploying
center : [Locations.latitude,Locations.longitude], //this location is same as Firebase one
radius : 10.0
});
const onKeyEnteredRegistration = geoQuery.on("key_entered", function(key, location) {
console.log(key + " entered the query. Hi " + key + "!");
});
}
Получил что-то подобное в npm
npm ERR! peer dep missing: firebase@^2.4.0 || 3.x.x || 4.x.x || 5.x.x, required by geofire@5.0.1
мой Firebase