Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created October 12, 2016 21:04
Show Gist options
  • Save jhyland87/c3f14850b5cf8dae757104870c1d7039 to your computer and use it in GitHub Desktop.
Save jhyland87/c3f14850b5cf8dae757104870c1d7039 to your computer and use it in GitHub Desktop.
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