Search code examples
node.jsfirebasegeofire

How to set Geofire in node.js


I'm a newbie in NodeJS as well in Geofire. So, I want to know wheter is possible to set Geofire in NodeJS or not. I've tried to do the following: ...

var geofire = require('geofire')
var firebase = require('firebase');
var db = new firebase.database();
var ref = db.ref('path/to/repo');
geofire = new Geofire(ref) ; // THIS DOESN'T WORK.

I couldn't set geofire object properly. How could I do it in the right way?


Solution

  • I think you need to respect the case in your first line :

    var GeoFire = require('geofire');
    

    then

    var firebaseRef = firebase.database().ref();
    // Create a GeoFire index
    var ref = new GeoFire(firebaseRef);
    

    Let me know if this works.