20 lines
582 B
JavaScript
20 lines
582 B
JavaScript
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$;
|
|
}
|