connect sequelize.js to node-webkit desktop app using sqlite
angularjs, javascript, node-webkit, sequelize.js, sqlite
Solution
I found the solution. after using following sqlite3 for node-webkit and rebuilding it as in the
node sqlite 3 for node-webkit It creates a folder named "node_sqlite3" inside the node_modules . I renamed "node_sqlite3" to "sqlite3". and then did npm-install of sequelize-sqlite . after this sequelize-sqlite automatically recognizes and gets connected to sqlite3 and it can normally be used.
var Sequelize = require('sequelize-sqlite').sequelize
var sqlite = require('sequelize-sqlite').sqlite
var sequelize = new Sequelize('database', 'username', '', {
dialect: 'sqlite',
storage: 'file:data.db'
})
var Record = sequelize.define('Record', {
name: Sequelize.STRING,
quantity: Sequelize.INTEGER
})
sequelize.sync()
.success(function(){
console.log('synced')
})
var rec = Record.build({ name: "sunny", quantity: 3 });
rec.save()
.error(function(err) {
// error callback
alert('somethings wrong')
})
.success(function() {
// success callback
console.log('inserted')
});
and the records are in the database.
Problem
currently I am using node-sqlite3 sqlite binding on my node-webkit desktop app and using it as ``` var sqlite3 = require('node_sqlite3').verbose(); var db = new sqlite3.Database('file:data.db'); db.run(query); ``` and on my knowledge this natively compiled node-sqlite3 is the only way to use sqlite db with node-webkit. now I want to use sequelize on the app which is normally used as: ``` var Sequelize = require('sequelize-sqlite').sequelize var sqlite = require('sequelize-sqlite').sqlite var sequelize = new Sequelize('database', 'username', 'password', { dialect: 'sqlite', storage: 'path/to/database.sqlite' }) sequelize.query("SELECT * FROM myTable").success(function(myTableRows) { console.log(myTableRows) }) ``` how can I achieve this ? (ie. use sequelize on node-webkit app with sqlite) the goal is to make the database life easier by running migrations , use models to manipulate database , or suggest if there are any other javascript libraries (mvc is prefered) , which can work through node-webkit+sqlite (and how to make them work) . is angularjs an option ? if yes how to do this. thank yous.