forked from neumino/thinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
37 lines (32 loc) · 902 Bytes
/
test.js
File metadata and controls
37 lines (32 loc) · 902 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
33
34
35
36
37
var config = require(__dirname+'/config.js');
var thinky = require(__dirname+'/lib/thinky.js')(config);
var r = thinky.r;
var Errors = thinky.Errors;
var util = require(__dirname+'/test/util.js');
var assert = require('assert');
var tableName = util.s8();
var Test = thinky.createModel(tableName, {
id: Number,
'f': {
_type: Number,
validator: function(value) {
return value == undefined || value == 42;
}
}
});
/*
var t = new Test({id: 1, f: 2});
t.save().then(console.log).error(console.log).finally(function() {
r.table(tableName).run().then(console.log)
})
*/
var t = new Test({id: 1});
t.save().then(function() {
console.log("saved")
t.f = 1;
t.save().then(function() {
console.log("updated")
}).catch(console.log).finally(function() {
r.table(tableName).run().then(console.log)
})
}).catch(console.log)