forked from strongloop/loopback-example-database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomigrate.js
More file actions
32 lines (28 loc) · 712 Bytes
/
automigrate.js
File metadata and controls
32 lines (28 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var path = require('path');
var app = require(path.resolve(__dirname, '../server/server'));
var ds = app.datasources.accountDS;
ds.automigrate('Account', function(err) {
if (err) throw err;
var accounts = [
{
email: 'john.doe@ibm.com',
createdAt: new Date(),
lastModifiedAt: new Date()
},
{
email: 'jane.doe@ibm.com',
createdAt: new Date(),
lastModifiedAt: new Date()
}
];
var count = accounts.length;
accounts.forEach(function(account) {
app.models.Account.create(account, function(err, model) {
if (err) throw err;
console.log('Created:', model);
count--;
if (count === 0)
ds.disconnect();
});
});
});