2018-06-07 21:35:06 +00:00
|
|
|
import { Observable } from 'rx';
|
|
|
|
|
|
|
|
export default function(Donation) {
|
|
|
|
Donation.on('dataSourceAttached', () => {
|
2018-11-29 14:24:17 +00:00
|
|
|
Donation.find$ = Observable.fromNodeCallback(Donation.find.bind(Donation));
|
2018-06-07 21:35:06 +00:00
|
|
|
Donation.findOne$ = Observable.fromNodeCallback(
|
|
|
|
Donation.findOne.bind(Donation)
|
|
|
|
);
|
|
|
|
});
|
2018-11-29 14:24:17 +00:00
|
|
|
|
|
|
|
function getCurrentActiveDonationCount$() {
|
|
|
|
// eslint-disable-next-line no-undefined
|
|
|
|
return Donation.find$({ where: { endDate: undefined } }).map(
|
|
|
|
instances => instances.length
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Donation.getCurrentActiveDonationCount$ = getCurrentActiveDonationCount$;
|
2018-06-07 21:35:06 +00:00
|
|
|
}
|