I'm using Loopback 3 to create API, I have model like this
Section.js
Section.json
Output
I want to subtract start_date to -7 hours so that it becomes like this
...
"start_date": "2019-06-23T17:00:00.000Z",
...
I try using getter from this thread How do I create getter and setter overrides? like this
but nothing has changed, did I implement it wrong?
Yes Now you have to call the Section.setup()
at the end. This is the default User
model.
So basically,
module.exports = function(User) {
User.setup = function() {
// We need to call the base class's setup method
User.base.setup.call(this);
var UserModel = this;
UserModel.setter.email = function(value) {
if (!UserModel.settings.caseSensitiveEmail) {
this.$email = value.toLowerCase();
} else {
this.$email = value;
}
};
return UserModel;
};
/*!
* Setup the base user.
*/
User.setup();
};
I don't know properly how to do that, but I made one MCVE that seemed to work(with bugs):
module.exports = function(Some) {
Some.setup = function() {
Some.base.setup.call(this);
var UserModel = this;
Some.getter.name = function(){
console.log(this.$name);
return this.$name+"lol";
}
}
Some.setup();
};