javascript - SQL Server 2008 on Node.js with Sequelize -
i'm new here !
i'm trying query on ms sql server2008 sequelize, error:
unhandled rejection sequelizedatabaseerror: invalid column name 'id'. @ query.formaterror (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_modules\s equelize\lib\dialects\mssql\query.js:217:10) @ request.usercallback (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_module s\sequelize\lib\dialects\mssql\query.js:66:25) @ request.callback (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_modules\te dious\lib\request.js:30:27) @ connection.state.sent_client_request.events.message (c:\xampp\htdocs\lavo ri\bit_sense\api_bs\node_modules\tedious\lib\connection.js:283:29) @ connection.dispatchevent (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_mo dules\tedious\lib\connection.js:752:59) @ messageio. (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_modul es\tedious\lib\connection.js:685:22) @ messageio.emit (events.js:104:17) @ messageio.eventdata (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_modules \tedious\lib\message-io.js:58:21) @ socket. (c:\xampp\htdocs\lavori\bit_sense\api_bs\node_modules\ tedious\lib\message-io.js:3:59) @ socket.emit (events.js:107:17) @ readableaddchunk (_stream_readable.js:163:16) @ socket.readable.push (_stream_readable.js:126:10) @ tcp.onread (net.js:538:20)
i've installed module: - sequelize ; - tedious ;
i haven't problem on connection, query:
db.key_arti.findall({ where:{ cacodice: cacodice } }).then(function(data) { res.send(data); });
what can ? haven't column called id
here table:
var sequelize = require('sequelize'); var settings = global.settings.databases.database; var errors = global.errors; var utilities = global.utilities; var sequelize = new sequelize(settings.schema, settings.username, settings.password, { dialect: settings.dialect, host: settings.host, port: settings.port, /* bisogna usare la dynamic port */ logging: function (str) { if(settings.log) console.log("querylog: "+str.replace("executing (default):", "") ); }, }); sequelize.authenticate().then(function(err) { if (!!err) { console.log('database '+settings.schema+' connection error:', err) } else { console.log('database '+settings.schema+' connected') } }); exports.sequelize = sequelize; /* * key_arti */ exports.key_arti = sequelize.define('key_arti', { cacodice: sequelize.char(20), cadesart: sequelize.char(40), }
by default, sequelize add primary key called id, if don't yourself.
sequelize.define('model', {}); // adds id key sequelize.define('model', { name: { primarykey: true type: sequelize.string } }); // doesn't add id, because marked column primary key
it possible have model without primary key, wouldn't recommend this
Comments
Post a Comment