Created
October 12, 2016 21:04
-
-
Save jhyland87/c3f14850b5cf8dae757104870c1d7039 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var hunt = require('hunt'), | |
huntSequilize = require('hunt-sequilize'), | |
Hunt = hunt({ | |
'sequelizeUrl': 'sqlite://localhost/' //create database in memory | |
}); | |
huntSequilize(Hunt); //this it it | |
Hunt.extendModel('Planet', function (core) { | |
return core.sequelize.define('Planet', { | |
name: core.Sequelize.STRING | |
}); | |
}); | |
Hunt.on('start', function () { | |
Hunt.sequelize.sync().success(function () { | |
Hunt.model.Planet.create({ | |
name: 'Earth' | |
}).success(function (planet) { | |
console.log('Planet "'+planet.name+'" is recorded to database'); | |
Hunt.model.Planet | |
.find({ where: {name: 'Earth'} }) | |
.success(function (planetFound) { | |
console.log('Planet "'+planetFound.name+'" is found to database'); | |
Hunt.stop(); | |
}); | |
}); | |
}); | |
}); | |
Hunt.startBackGround(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment