简体   繁体   中英

Creating/saving Loopback model programmatically

I am trying to use

// item is some string representing model name

const Model = app.models[item];

Model.create([array of model data],{options}, function(a, b, c){


});

but this API is giving me hell, it seems to fire the callback inconsistently if at all, and also, {a,b,c}, seem to be totally inconsistent, in other words, Model.create does not seem to fire a standard error first callback and I simply cannot figure out what it is passing back, seems to be very inconsisent.

I filed an issue on Github for Loopback on this, but I am wondering if there is a better API for programmatically creating models like this.

I am trying to seed our test database with data.

There is no second optional parameter .

Model.create({propA: value /*, etc */}, function(err, results){

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM