loopbackjs - loopback reference to a model -
I am trying to refer to a model in the first save function of another model using this documentation: And it does not seem to work. I am forgetting something, can anyone help?
(model1.js) var loopback = expected ('loopback'); Var app = module Exports = Loopback (); Module.exports = function (model 1) {Model1.beforeSave = function (next, obj) {if (obj.relation ()) come back (); Console.log (app.models.Model2); //the upcoming(); }};
ignoring the "relationship" part of your sample, here it is How your code should look ...
module.exports = function (Model1) {Model1.beforeSave = function (Next, obj) {// if (obj.relation ()) next ( ); Console.log (Model1.app.models.Model2); // or console.log (Model1.app.models ('Model2')); Next (empty, OBG); // "zero" = "no error" and you can modify the oboes in some way above}};
Comments
Post a Comment