I have a list of categories and a list of places, there is a categorieId in the foreign key in each place.
categorie.json:
place.json:
I try to verify whether the category id exists or not. For this, I redefine the method of making one in the square. In the place category, I find that the class ID is present in the category. If I have found it, then I call the method of the method to insert data in place. But remembering this uptrend method creates a method ... If I do not call the Apache method, then the data does not get included. How strong can I verify and data?
script.js:
module.exports = function (app) {var Place = App.models.place; Var Classification = AP Models.categorie; Place.create = function (data, callback) {console.log ("avant find"); Console.log (data.id); Categorie.findById (data.categorieId, function (err, instance) {console.log ("find") if (mistake) {throw throw;} if (example == empty) {new error; throw error;} console.log ("Upset"); place aperta (data, callback);}); }; };
You should redefine the remote method, not the ORM method.
Another approach, if you use Relational DB, then create foreign key barriers.
Here is the SQL query, where location
and categorie
are the table names: Add optional table location Insert category category_plus_ics foreign key (categorieId) Delete the references (id) on deleted SET NULL;
No comments:
Post a Comment