Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created August 22, 2013 03:31
Show Gist options
  • Save thomasboyt/6302912 to your computer and use it in GitHub Desktop.
Save thomasboyt/6302912 to your computer and use it in GitHub Desktop.
Sequelize = require("sequelize")
sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'sqlite',
})
Post = sequelize.define('Post', {
title: Sequelize.STRING
date: Sequelize.DATE
body: Sequelize.TEXT
})
Post.sync()
post = Post.build({
title: 'first post'
date: Date.now()
body: 'This is an autogenerated post'
})
post.save().error((err) ->
console.log 'Error while saving: ' + err
).success(() ->
console.log 'Saved properly'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment