Created
February 29, 2016 02:58
-
-
Save royaltm/36ed4640ab3251bcc74b to your computer and use it in GitHub Desktop.
an example for https://github.com/scottwrobinson/camo/issues/57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// https://github.com/scottwrobinson/camo/issues/57 | |
const Document = require('camo').Document; | |
const assert = require('assert'); | |
class Foo extends Document { | |
constructor() { | |
super(); | |
this.bar = String; | |
} | |
preValidate() { | |
return Promise.reject("must not save!"); | |
} | |
} | |
var connect = require('camo').connect; | |
var database; | |
var uri = 'nedb://memory'; | |
connect(uri).then(() => { | |
console.log("I am unstoppable!!!"); | |
return Foo.create({bar: 'bar'}).save(); | |
}) | |
.then(() => { | |
assert.ifError("You can't stop me do you?"); | |
}, err => { | |
assert.strictEqual(err , "must not save!"); | |
console.log("OK: well, it did stop me.... phew!"); | |
}) | |
.catch(e => console.log("FAIL: %s", e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment