mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-16 12:36:01 +00:00
Fix code to work on this decade 1/x
This commit is contained in:
22
funcs/dbget.js
Normal file
22
funcs/dbget.js
Normal file
@ -0,0 +1,22 @@
|
||||
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;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user