Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async fetch(transaction) {
try {
let snapshot;
if (transaction) {
if (transaction instanceof firebase.firestore.Transaction) {
snapshot = await transaction.get(this.reference);
}
if (transaction instanceof FirebaseFirestore.Transaction) {
snapshot = await transaction.get(this.reference);
}
}
else {
snapshot = await this.reference.get();
}
const data = snapshot.data();
if (data) {
this.setData(data);
this.isSaved = true;
}
}
catch (error) {
throw error;
}
}
async get(type, transaction) {
try {
let snapshot;
if (transaction instanceof FirebaseFirestore.Transaction) {
const reference = this.reference;
snapshot = await transaction.get(reference);
}
else {
snapshot = await this.reference.get();
}
const docs = snapshot.docs;
const documents = docs.map((documentSnapshot) => {
const document = new type(documentSnapshot.id, {});
document.setData(documentSnapshot.data());
return document;
});
this.objects = documents;
return documents;
}
catch (error) {