sequelize.query() returns same result twice

I am working in nodejs project in that using sequelize for connecting mysql database. I am also using sequelize-values for getting raw data from Sequelize instances.

I have written below code

  • gcloud socketIO is not working on multi-instances
  • Managing Gulp dependencies when spawning child processes
  • How do I systematically replace text within mustache tags in a large body of text?
  • Large CSV to JSON/Object in Node.js
  • EXCEPTION: Token must be defined
  • Node.js: Read large text file only partialy
  • var Sequelize = require('sequelize');
    var sequelizeObj = new Sequelize('mysql://root:@localhost/database');
    sequelizeObj.authenticate().then(function (errors) {
    sequelizeObj.query("SELECT * FROM `reports` WHERE `id` = 1200").then(function (result) {

    Now the table reports have only 1 record for id 1200, But the result gives two objects for same records, Means both records are same of id 1200.

    [ [ { id: 1200,
      productivity_id: 9969,
      gross_percentage_points: 100 } ],
    [ { id: 1200,
      productivity_id: 9969,
      gross_percentage_points: 100 } ] ]

    Let me know what I am doing wrong?

  • Add the CSS from the node_modules folder using angular cli
  • passport's req.isAuthenticated always returning false, even when I hardcode done(null, true)
  • Redshift - unsupported type “serial” for auto increment id with node-orm-2
  • node.js - share sockets between processes
  • Removing documents from a mongodb collection from node.js
  • Phusion Passenger Error: http.Server.listen() was called more than once
  • 2 Solutions collect form web for “sequelize.query() returns same result twice”

    The first object is the result object, the second is the metadata object (containing affected rows etc) – but in mysql, those two are equal.

    Passing { type: Sequelize.QueryTypes.SELECT } as the second argument will give you a single result object (metadata object omitted

    Try :

    sequelizeObj.query("SELECT * FROM `reports` WHERE `id` = 1200", { type: Sequelize.QueryTypes.SELECT }).then(function (result) {

    Best regards,

    Node.js is the Best Javascript runtime in the world.