Skip to content

Instantly share code, notes, and snippets.

@scottwrobinson
Last active February 15, 2016 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwrobinson/ab5ae433d4f5295031a9 to your computer and use it in GitHub Desktop.
Save scottwrobinson/ab5ae433d4f5295031a9 to your computer and use it in GitHub Desktop.
Working example for use with babel-preset-camo (see Camo issue #17)
{
"presets": ["camo", "stage-0"]
}
import { connect, Document, EmbeddedDocument } from 'camo';
class Contact extends EmbeddedDocument {
name = String;
constructor () {
super('contact');
}
}
class Site extends Document {
name = String;
contacts = [Contact];
constructor () {
super('site');
}
}
connect('nedb://memory').then(db => {
console.log('Connected!');
const MA = Site.create({
name: 'Mass',
contacts: [{
name: 'One Guy'
}, {
name: 'Some Dude'
}]
});
console.log('Initialized new Site');
console.log('Saving...');
return MA.save();
}).then(data => {
console.log('SAVED:', data);
}).catch(err => {
console.error('ERROR:', err.stack);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment