fix(AccessToken): Move extensions to boot script
Loopback does not facilitate built in model extensions in the same way as user defined models
This commit is contained in:
committed by
mrugesh mohapatra
parent
0682ef33db
commit
8a66886081
@ -1,18 +0,0 @@
|
|||||||
import { Observable } from 'rx';
|
|
||||||
|
|
||||||
module.exports = AccessToken => {
|
|
||||||
// wait for datasource to attach before adding methods
|
|
||||||
// prevents loopback from unnecessarily
|
|
||||||
// adding watchers on startup
|
|
||||||
AccessToken.on('dataSourceAttached', () => {
|
|
||||||
AccessToken.findOne$ = Observable.fromNodeCallback(
|
|
||||||
AccessToken.findOne.bind(AccessToken)
|
|
||||||
);
|
|
||||||
AccessToken.prototype.validate$ = Observable.fromNodeCallback(
|
|
||||||
AccessToken.prototype.validate
|
|
||||||
);
|
|
||||||
AccessToken.prototype.destroy$ = Observable.fromNodeCallback(
|
|
||||||
AccessToken.prototype.destroy
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
15
server/boot/a-extend-built-ins.js
Normal file
15
server/boot/a-extend-built-ins.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Observable } from 'rx';
|
||||||
|
|
||||||
|
export default function extendEmail(app) {
|
||||||
|
const { AccessToken, Email } = app.models;
|
||||||
|
Email.send$ = Observable.fromNodeCallback(Email.send, Email);
|
||||||
|
AccessToken.findOne$ = Observable.fromNodeCallback(
|
||||||
|
AccessToken.findOne.bind(AccessToken)
|
||||||
|
);
|
||||||
|
AccessToken.prototype.validate$ = Observable.fromNodeCallback(
|
||||||
|
AccessToken.prototype.validate
|
||||||
|
);
|
||||||
|
AccessToken.prototype.destroy$ = Observable.fromNodeCallback(
|
||||||
|
AccessToken.prototype.destroy
|
||||||
|
);
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
import { Observable } from 'rx';
|
|
||||||
|
|
||||||
export default function extendEmail(app) {
|
|
||||||
const { Email } = app.models;
|
|
||||||
Email.send$ = Observable.fromNodeCallback(Email.send, Email);
|
|
||||||
}
|
|
Reference in New Issue
Block a user