I'm having db.js
file which consist of
var mysql = require('mysql2');
var mysqlModel = require('mysql-model');
var appModel = mysqlModel.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'tabio',
});
var User = appModel.extend({
first: "table_first",
});
var Message = appModel.extend({
second: "table_second",
});
module.exports = {
first : first,
second : second
};
I am requesting the db.js
in another file main.js
like
var connection = require('./db.js');
test = new connection.first({
column1: 12,
column2: 34,
});
test.save();
it successfully saves the recored. But how can i run select
, delete
, update
query here.
while using var test = connection.first.find(1);
, i get the error TypeError: connection.User.find is not a function
. how to use the select
& update
query using db-migrate
?