freeCodeCamp/api-server/server/models/donation.js

20 lines
582 B
JavaScript
Raw Normal View History

import { Observable } from 'rx';
export default function(Donation) {
Donation.on('dataSourceAttached', () => {
Donation.find$ = Observable.fromNodeCallback(Donation.find.bind(Donation));
Donation.findOne$ = Observable.fromNodeCallback(
Donation.findOne.bind(Donation)
);
});
function getCurrentActiveDonationCount$() {
// eslint-disable-next-line no-undefined
return Donation.find$({ where: { endDate: undefined } }).map(
instances => instances.length
);
}
Donation.getCurrentActiveDonationCount$ = getCurrentActiveDonationCount$;
}