File size: 555 Bytes
e3fefe8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | const { dbGetAll } = require('../config/firebase');
const TRANSACTIONS_PATH = 'transactions';
const TransactionModel = {
async getByProfessionalId(professionalId) {
const all = await dbGetAll(TRANSACTIONS_PATH);
return all
.filter((tx) => tx.professionalId === professionalId)
.sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0));
},
async getByBookingId(bookingId) {
const all = await dbGetAll(TRANSACTIONS_PATH);
return all.filter((tx) => tx.bookingId === bookingId);
},
};
module.exports = TransactionModel;
|