美文网首页
node 使用mysql模块查询Mysql数据库返回结果类型

node 使用mysql模块查询Mysql数据库返回结果类型

作者: createK | 来源:发表于2018-01-26 13:50 被阅读798次

nodemysql的查询中,查询的返回结果中。

  1. select * from table

    返回结果是数组 (Array)类型。结构是数组中包含对象。

    [{},{}]
    
  2. insert返回结果是Object类型,结果如下所示

    insert into table () values ()

    {
      fieldCount: 0,
      affectedRows: 1, //影响行数
      insertId: 481,   //ID
      serverStatus: 2,  //服务器状态
      warningCount: 0,  //警告
      message: '',     //信息
      protocol41: true,   //协议
      changedRows: 0   //改变的行数
    }
    
  3. update返回的结果类型为Object

    update table set xx = xx where xx = xx

    返回结果:

    { 
      fieldCount: 0,
      affectedRows: 1,
      insertId: 0,
      serverStatus: 2,
      warningCount: 0,
      message: '(Rows matched: 1  Changed: 1  Warnings: 0',
      protocol41: true,
      changedRows: 1
    }
    
  4. delete 返回的结果类型为 Object

    delete from table where xx = xx

    返回结果:Object

    { 
      fieldCount: 0,
      affectedRows: 1,
      insertId: 0,
      serverStatus: 2,
      warningCount: 0,
      message: '(Rows matched: 1  Changed: 1  Warnings: 0',
      protocol41: true,
      changedRows: 1
    }
    

相关文章

网友评论

      本文标题:node 使用mysql模块查询Mysql数据库返回结果类型

      本文链接:https://www.haomeiwen.com/subject/fdaiaxtx.html