mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-14 03:30:18 +00:00
22 lines
662 B
JavaScript
22 lines
662 B
JavaScript
module.exports = async function (collection, doc, client) {
|
|
if (doc) {
|
|
let d = await client.db.collection(collection).doc(doc).get().catch(err => {
|
|
console.log('Error getting document', err);
|
|
return 'error';
|
|
});
|
|
return d.data();
|
|
} else {
|
|
let d = await client.db.collection(collection).get().catch(err => {
|
|
console.log('Error getting document', err);
|
|
return 'error';
|
|
});
|
|
let finalD = [];
|
|
d.forEach(doc => {
|
|
finalD.push({
|
|
id: doc.id,
|
|
d: doc.data(),
|
|
});
|
|
});
|
|
return finalD;
|
|
}
|
|
}; |