Closed janek26 closed 7 years ago
Works for me:
var thinky = require('./lib/thinky.js')();
var type = thinky.type;
var Model = thinky.createModel('Foo', {
id: type.string(),
age: type.number()
});
Model.pre('save', function(next) {
if (this.age > 18) {
next();
} else {
next(new Error('FOO'));
}
});
var a = new Model({
id: 'bar',
age: 2
});
a.save().then(function() {
console.log('Success save');
}).error(function() {
console.log('Failure save');
}).finally(function() {
return Model.get('bar').run();
}).then(function() {
console.log('Success retrieve');
}).error(function() {
console.log('Failure retrieve');
});
$ node test.js
Creating a pool connected to localhost:28015
Failure save
Failure retrieve
Please provide a script if that's still an issue.
My code is like:
In this case I thought thinky is just saving when next() is called without arguments, or do I miss something? Thinky does save anyway, even if the password in this case isn't strong enough!