Why the objects returned by sequelize findAll and the likes cannot be modified like regular objects? I checked if they are frozen or locked, but Object.isFrozen() returns false. Does it use getters instead of real properties (how do I check that?)
So far my only option to modify the results is to do JSON.parse(JSON.strigify(result)) which is OK, but incurs performance price.
Your instances have getters and setters methods. You can call instance.get('field') or instance.set('field', value).
But If you are trying to dynamically add a new property to your model, you can try to create a property type : DataTypes.VIRTUAL.
DataTypes.VIRTUAL properties are transients, you can use to customize/add properties value that you dont want to be persisted to database.
http://docs.sequelizejs.com/en/v3/api/datatypes/#virtual
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With