-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add a new readonly
property to Model fields definition
#4603
Comments
Good idea. Good candidate for a plugin |
@mickhansen I want to do it, but I don't know where to start (I didn't found in the docs how to do sequelize plugins). Can you point me towards the right direction so I can do it? Thanks |
I would simply wrap |
@mickhansen Thanks, I will give it a try. |
https://github.com/mickhansen/ssacl-attribute-roles does some of the same stuff, you can check out the code there. |
Sorry, for the delay on this, I was busy on other things. I've the doubt now, what approach will you prefer?:
Thing is that with the setter approach the Thanks! |
If you wrap the setter method you can choose to ignore the raw option. |
@mickhansen Nice! I will continue with that option then, thanks! |
I came across this looking for a way to create a model based on a view (db-level) that would only attempt to save the fields in the underlying base table. For example, the view might have a part number and description that are associated with a PartID. When I save the record, I don't want the related fields to be saved, just the PartID itself. It seems to me that this is truly "readonly" and the implementation being suggested is more "noupdate". |
@TonyNLewis are you looking to disallow all writes (i.e. both initial and update) or just updates? Is part number allowed to be updated if it is currently null? You could take a look at: https://github.com/mickhansen/ssacl-attribute-roles |
Finally got the time to do this 😄 @TonyNLewis I accepted your suggestion and named the plugin I added the new plugin at the wiki https://github.com/sequelize/sequelize/wiki/Add-ons-&-Plugins npm location: https://www.npmjs.com/package/sequelize-noupdate-attributes Thanks @mickhansen for your help. |
This definetly should be in core. ReadOnly option is a must have for ORMs. |
Please consider it as core feature, gentlemen. |
why not something more standard like Model says "oh you got an email update for me?... https://www.youtube.com/watch?v=lWtPFv194GU |
Any update on this? |
? |
Any update? |
new year, new update? :-) |
I have reopened this but it is going to be low priority, since there is already a plugin to do this |
One year later, still would like this :) |
Let's implement this 😌 |
@juice-shop could really use this feature, as we're currently doing it via a third party module, but that doesn't work with TypeScript and kind of blocks our migration now. |
Bumping this feature request :) |
readonly
will be a boolean property by default set to false.Its operation can be something like:
readonly
error.readonly
error.This come in handy when manipulating this kind of fields, which is a common use case I think (I've the need of this kind of model fields across several different projects).
So, what do you think?
The text was updated successfully, but these errors were encountered: