Sequelize findOne没有按预期工作

时间:2016-04-01 17:38:56

标签: javascript mysql sql node.js sequelize.js

以下功能应从模型服务器中获取一条记录,其中field' game'是' 5'

Servers.findOne({ where: { game : '5' } }).then(function(s){
            fetched(s);
    });
  1. 预期查询

      

    SELECT ... WHERE'游戏' =' 5'

  2. 通过续集生成并执行的查询

      

    执行(默认):SELECT id AS idaddress AS addressport AS portgame AS gamepriority AS prioritycreatedAtupdatedAt FROM Servers AS Servers WHERE 1 = 1 < / strong> LIMIT 1;

  3. Server.js(模型文件)

    var Sequelize = require("sequelize");
    
    module.exports=function(sequelize, DataTypes){ 
      return sequelize.define("Servers", {
        id: {
          type: DataTypes.INTEGER, 
          field: "id",             
          autoIncrement: !0,       
          primaryKey: !0
        },
        address: {               
          type: DataTypes.STRING,  
          field: "address"      
        },
        port: {                
          type: DataTypes.STRING,  
          field: "port"       
        },
        game: {
          type: DataTypes.INTEGER,
          field: "game"
        },
        priority: {
          type: DataTypes.INTEGER,
          field: 'priority'
        }
      }, 
      {
        freezeTableName: true, // Model tableName will be the same as the model name
        classMethods:{
    
          },
        instanceMethods:{
    
        }
    
      });
    };
    

    我在这里缺少什么?我

0 个答案:

没有答案