Last active
February 15, 2016 22:53
-
-
Save scottwrobinson/ab5ae433d4f5295031a9 to your computer and use it in GitHub Desktop.
Working example for use with babel-preset-camo (see Camo issue #17)
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
Show hidden characters
{ | |
"presets": ["camo", "stage-0"] | |
} |
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
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