forked from verily-org/verily
-
Notifications
You must be signed in to change notification settings - Fork 0
/
populate.js
37 lines (32 loc) · 1.08 KB
/
populate.js
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
33
34
35
36
37
var orm = require("orm");
orm.connect("sqlite://app.db", function (err, db) {
//
// Instance.cache is an important setting.
// By default the cache is enabled but this means
// that fields set not in the create() function will not be
// picked up by the model (all fields successfully save into DB).
db.settings.set('instance.cache', false);
db.load("./models", function (err) {
var User;
if (err === null || err === undefined) {
console.log('Model loaded');
} else {
console.log('Model loading failed:');
console.log(err);
}
db.sync(function () {
console.log('model-synced');
User = db.models.user;
User.create(
[{'name': 'test',
'role':'editor'},],
function (err, items) {
console.log('err:', err);
console.log('items:', items);
User.find({}, function (err, items) {
console.log(items);
});
});
});
});
});