Created
June 12, 2019 07:01
-
-
Save pookdeveloper/37e249aa0195fd27b63355c515a388f8 to your computer and use it in GitHub Desktop.
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