Created
June 12, 2019 07:01
Loopback 3 overrride default method of controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function (Examplemodel) { | |
var app = require('../../server/server'); | |
var seguridad = require('../seguridad/seguridad'); | |
var utilidades = require('../utilidades/utilidades'); | |
// Override the method create for model | |
Examplemodel.once('attached', function () { | |
var _create = Examplemodel.create; | |
Examplemodel.create = function (filter, options, cb) { | |
_create.apply(this).then((data => { | |
// DO SOMETHING | |
cb(null, data) | |
})).catch((err => { | |
// DO SOMETHING | |
cb(err) | |
})) | |
} | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment