Skip to content

Instantly share code, notes, and snippets.

@royaltm
Created February 29, 2016 02:58
Show Gist options
  • Save royaltm/36ed4640ab3251bcc74b to your computer and use it in GitHub Desktop.
Save royaltm/36ed4640ab3251bcc74b to your computer and use it in GitHub Desktop.
"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