hauru / sequelize-to-json

Serialization of Sequelize models into JSON-compatible objects
21 stars 13 forks source link

Not working with Sequelize v4.1.0 #4

Closed yelled3 closed 7 years ago

yelled3 commented 7 years ago
class extends Model {} is not a valid Sequelize model
Error: class extends Model {} is not a valid Sequelize model
    at new Serializer ([...]/node_modules/sequelize-to-json/index.js:91:13)
let serializer = new Serializer(Item, scheme);
let res = serializer.serialize(Item);
// item model

module.exports = (sequelize, DataTypes)=> {
  const Position = sequelize.define('Item', {
    name: DataTypes.STRING,
  });
  return Item;
};

@hauru this seems to be the issue:

https://github.com/hauru/sequelize-to-json/blob/master/index.js#L90-L92

hauru commented 7 years ago

Sequelize 4.x has introduced some breaking changes and sequelize-to-json won't work properly with it. I'll be looking into this shortly. In the meantime, here's a pull request updating the module to cooperate with Sequelize 4: https://github.com/hauru/sequelize-to-json/pull/5

yelled3 commented 7 years ago

fixed in https://github.com/hauru/sequelize-to-json/commit/a94b6d4c546a65e25e820ea595476e2fc58464d1

thanks @hauru