Last active
June 9, 2022 18:05
-
-
Save izotx/061e96cc9f49c63fc4bc2c22edb79188 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var firebase = require("firebase"); | |
var RSVP = require('rsvp'); | |
exports.getInstance = function(){ | |
initFirebase() | |
return firebase | |
} | |
/**Responsible for initalizing firebase database.*/ | |
function initFirebase(){ | |
var config = { | |
apiKey: "AIzaSyB1As1MtKDc7iNA5GEqf0W6f_k1bQNzJFE", | |
authDomain: "summerhousing-5c0cf.firebaseapp.com", | |
databaseURL: "https://summerhousing-5c0cf.firebaseio.com", | |
projectId: "summerhousing-5c0cf", | |
storageBucket: "summerhousing-5c0cf.appspot.com", | |
messagingSenderId: "493524743868" | |
}; | |
firebase.initializeApp(config); | |
} | |
/**Helper for getting collections*/ | |
exports.getCollection = function (collectionName){ | |
var promise = new RSVP.Promise(function(fulfill, reject) { | |
firebase.database().ref(collectionName).on("value", function(snapshot) { | |
// console.log(snapshot); | |
let array = [] | |
// let colleges = snapshot.val(); | |
snapshot.forEach(function(snap){ | |
var el = snap.val() | |
el.key = snap.key | |
array.push(el) | |
}); | |
fulfill(array) | |
}); | |
}); | |
return promise | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment