Sequelize classMethods vs instanceMethods

后端 未结 3 1568
盖世英雄少女心
盖世英雄少女心 2021-02-12 23:48

So starting my adventure into all things Node. One of the tools I am trying to learn is Sequelize. So I will start off what I was trying to do:



        
3条回答
  •  粉色の甜心
    2021-02-13 00:17

    I found this worked for me as of sequelize 3.14

    var myModel = sequelize.define('model', {
    
    }, {
      classMethods: {
        someClassMethod: function() {
          return true;
        }
    }, {
      instanceMethods: {
        callClassMethod: function() {
          myModel.someClassMethod();
        }
      }
    });
    

提交回复
热议问题