• <small id='T6sqc'></small><noframes id='T6sqc'>

    <legend id='T6sqc'><style id='T6sqc'><dir id='T6sqc'><q id='T6sqc'></q></dir></style></legend>
      <bdo id='T6sqc'></bdo><ul id='T6sqc'></ul>
      <i id='T6sqc'><tr id='T6sqc'><dt id='T6sqc'><q id='T6sqc'><span id='T6sqc'><b id='T6sqc'><form id='T6sqc'><ins id='T6sqc'></ins><ul id='T6sqc'></ul><sub id='T6sqc'></sub></form><legend id='T6sqc'></legend><bdo id='T6sqc'><pre id='T6sqc'><center id='T6sqc'></center></pre></bdo></b><th id='T6sqc'></th></span></q></dt></tr></i><div id='T6sqc'><tfoot id='T6sqc'></tfoot><dl id='T6sqc'><fieldset id='T6sqc'></fieldset></dl></div>
        <tfoot id='T6sqc'></tfoot>

        TypeError:无法读取未定义的属性“findAll"(expressjs)

        时间:2023-09-03

          <tbody id='cZxuY'></tbody>

          <small id='cZxuY'></small><noframes id='cZxuY'>

              <bdo id='cZxuY'></bdo><ul id='cZxuY'></ul>
              <tfoot id='cZxuY'></tfoot>

              <legend id='cZxuY'><style id='cZxuY'><dir id='cZxuY'><q id='cZxuY'></q></dir></style></legend>
                • <i id='cZxuY'><tr id='cZxuY'><dt id='cZxuY'><q id='cZxuY'><span id='cZxuY'><b id='cZxuY'><form id='cZxuY'><ins id='cZxuY'></ins><ul id='cZxuY'></ul><sub id='cZxuY'></sub></form><legend id='cZxuY'></legend><bdo id='cZxuY'><pre id='cZxuY'><center id='cZxuY'></center></pre></bdo></b><th id='cZxuY'></th></span></q></dt></tr></i><div id='cZxuY'><tfoot id='cZxuY'></tfoot><dl id='cZxuY'><fieldset id='cZxuY'></fieldset></dl></div>
                  本文介绍了TypeError:无法读取未定义的属性“findAll"(expressjs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  TypeError:无法读取未定义(expressjs)的属性findAll".

                  TypeError: Cannot read property 'findAll' of undefined (expressjs).

                  所有功能(续集)都不起作用.所有错误:无法读取属性续集方法"...

                  All functions (sequelize) are not working. All errors: Cannot read property 'sequelize method' ...

                  module.exports = function (sequelize, DataTypes) {
                  var User = sequelize.define('user', {
                      email: {type: DataTypes.STRING(32), unique: true, allowNull: false},
                  });
                  
                  return User;
                  };
                  

                  控制器:

                  models  = require('./../models');
                  
                  exports.index = function (request, response, next) {
                      models.User.findAll({attributes: ['id', 'username']});
                  };
                  

                  推荐答案

                  我遇到了同样的问题,下面的更改对我有用.这可能对未来的用户有用 -

                  I had the same issue, and the changes below worked for me. This might be useful for future users -

                  当你使用sequelize模型时,你需要使用定义好的模型类名,在findAll行中是user"而不是User":

                  when you use the sequelize model you need to use the defined model class name, which is "user" instead of "User" in line findAll:

                  models  = require('./../models');
                  exports.index = function (request, response, next) {
                      models.user.findAll({attributes: ['id', 'username']});
                  };
                  

                  用户"是分配了续集定义的变量,并且在该模型定义之外无法识别.用户"是正在创建的表名以及 sequelize 模型类名,这需要在任何类型的数据库查询中使用.

                  The "User" is a variable to which the sequelize definition is assigned and its not recognized outside that model definition. The "user" is the table name that is getting created as well as the sequelize model class name, and this needs to be used in any type of db query.

                  这篇关于TypeError:无法读取未定义的属性“findAll"(expressjs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Sequelize 带有日期的 Where 语句 下一篇:Javascript异步函数流程

                  相关文章

                    <bdo id='kkyai'></bdo><ul id='kkyai'></ul>

                    <i id='kkyai'><tr id='kkyai'><dt id='kkyai'><q id='kkyai'><span id='kkyai'><b id='kkyai'><form id='kkyai'><ins id='kkyai'></ins><ul id='kkyai'></ul><sub id='kkyai'></sub></form><legend id='kkyai'></legend><bdo id='kkyai'><pre id='kkyai'><center id='kkyai'></center></pre></bdo></b><th id='kkyai'></th></span></q></dt></tr></i><div id='kkyai'><tfoot id='kkyai'></tfoot><dl id='kkyai'><fieldset id='kkyai'></fieldset></dl></div>

                    <legend id='kkyai'><style id='kkyai'><dir id='kkyai'><q id='kkyai'></q></dir></style></legend><tfoot id='kkyai'></tfoot>

                    <small id='kkyai'></small><noframes id='kkyai'>