且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Sequelize ORM中添加自定义DataType

更新时间:2023-02-06 21:03:38

https://github.com/sequelize/sequelize/blob/master/lib/data-types.js 保存续集数据类型。

具体来说, https://github.com/sequelize/sequelize/blob/master/lib/data-types.js#L251-L273 显示了DataTypes.INTEGER如何继承自DataTypes.NUMBER使用 NUMBER.inherits(fn)

Specifically, https://github.com/sequelize/sequelize/blob/master/lib/data-types.js#L251-L273 shows how DataTypes.INTEGER inherits from DataTypes.NUMBER using NUMBER.inherits(fn).

那些继承自ABSTRACT。您可以为继承的数据类型覆盖 toString()方法,如 https://github.com/sequelize/sequelize/blob/master/lib/data-types.js#L62-L64

Those inherit from ABSTRACT. You could override the toString() method for your inherited data type like as seen at https://github.com/sequelize/sequelize/blob/master/lib/data-types.js#L62-L64.

免责声明:由于未公开记录,我不确定API的稳定程度,并且由于未来可能的变化而会保持谨慎。

Disclaimer: with it not being publicly documented, I am not sure how stable the APIs are and would be cautious due to possible future changes.