Skip to content

Instantly share code, notes, and snippets.

@BradCoffield
Created November 22, 2019 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BradCoffield/e8437f00cd958503029ec00f68872240 to your computer and use it in GitHub Desktop.
Save BradCoffield/e8437f00cd958503029ec00f68872240 to your computer and use it in GitHub Desktop.
module.exports = function getValues(theCollection) {
console.log("start");
var result;
return db //note this return________
.collection(theCollection)
.get()
.then(snapshot => {
let theData = [];
snapshot.forEach(doc => {
theData.push({ [doc.id]: doc.data() });
});
result = theData;
console.log("HERE WE BE");
return result; //note this return__________
})
.catch(err => {
console.log("Error getting documents", err);
});
}
let dataAccess = require("../db");
(async () => {
try {
let rez = await dataAccess.getFirestoreCollection(theCollection);
res.send(rez);
} catch (err) {
console.log("ERROR:", err);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment