timy-messenger/firebase/functions/group-util.js
Franz Heinfling 64d39ac266 Initial commit.
Co-authored-by: Miguel Beltran <m@beltran.work>
2019-10-01 17:26:36 +02:00

25 lines
501 B
JavaScript

const { db } = require('./admin');
const getAllGroups = async () => {
let groupDocs = await db
.collection('groups')
.get();
if (groupDocs.empty) {
console.log('Could not find any groups');
return null;
}
return groupDocs;
}
const getGroupName = async (groupId) => {
let groupDoc = await db
.collection('groups')
.doc(groupId)
.get();
return groupDoc.data().name;
}
module.exports = { getGroupName, getAllGroups };