1

I'm trying to poulate my Strongloop models and relations during startup. I've created a js-script in server/boot/ but how do I initialize a hasAndBelongsToMany relation?

This is what my current setup code looks like (some parts omitted for brevity):

module.exports = function(app) {
  app.dataSources.mySqlDb.automigrate(['X', 'Y'], function(err) {
    app.models.X.create([{ fuu: "bar"}, (some more...)], function(err, xs) {});
    app.models.Y.create([{ foo: "baz"}, (some more...)], function(err, ys) {});
  });
};

In the X model (x.json) there is a hasAndBelongsToMany relation defined to Y, but how and where can I add data to it?

4ZM
  • 1,463
  • 1
  • 11
  • 21
  • yes docs are silent on how to do this. it's also broken I believe and not working. – user798719 May 18 '15 at 15:44
  • you can insert data and then in the callbacks update the necessary relations via the node api that is generated but I found it very difficult to maintain, I ended up inserting test data directly into the db – stevejpurves Nov 10 '15 at 22:55

0 Answers0