Skip to content

Instantly share code, notes, and snippets.

@pookdeveloper
Created June 12, 2019 07:01
Show Gist options
  • Save pookdeveloper/37e249aa0195fd27b63355c515a388f8 to your computer and use it in GitHub Desktop.
Save pookdeveloper/37e249aa0195fd27b63355c515a388f8 to your computer and use it in GitHub Desktop.
Loopback 3 overrride default method of controller
'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