Skip to content
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

UseCase : sequelize.fn in updates #13426

Open
Carl-Lspn opened this issue Aug 9, 2021 · 3 comments
Open

UseCase : sequelize.fn in updates #13426

Carl-Lspn opened this issue Aug 9, 2021 · 3 comments
Labels
type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.

Comments

@Carl-Lspn
Copy link

Issue Creation Checklist

[x] I have read the contribution guidelines

Issue Description

What was unclear/insufficient/not covered in the documentation

I'm currently trying to make updates on passwords using sequelize.fn.
I've seen numerous sites, including the Sequelize's manual, yet I found too few articles that approaches my case.

Moreover, the function to encrypt the passwords need nested function, so I need to gradually construct the nested function
by putting the successive arguments into variables.
I have not found anything on constructing the functions, thus using sequelize.fn outside the arguments of the functions find and updates.

If possible: Provide some suggestion on how we can enhance the docs

I may suggest adding more examples using sequelize.fn within updates, even if not nested, and/or adding exemples on constructing the update arguments outside the update function

Additional context

In my case, " crypt('password', gen_salt('bf', 4)) " (in Postgres) needs to become
sequelize.fn('crypt', 'password', sequelize.fn('gen_salt', 'bf', 4)) and to be stored into a variable
When I inject it into the update function, an Fn Object is injected, and the result in the database seems to be a memory address instead of the result of the crypt function.

I may post a code example so you can have a better understanding of what I'm trying to do and I think should be added into the documentation
I did not made this doc issue to resolve my issue, only to point out what I think is lacking in the documentation
I will ask StackOverflow for help regarding my issue.

Object.keys(req.message.attributes).map((key)=>{
  //req.message.attributes[key] contains the formatting needed to be put onto the value
  //e.g. crypt(password, gen_salt('bf', 4))
  //req.body[key] contains the value
  //e.g. '1234'
  let seqValue = util.recursSequelizeFn(req.message.attributes[key], req.body[key]);
  req.body[key] = seqValue;
});

mainModel.update(req.body, {where: {id:req.params.id}, logging:console.log})
.then() //...
@Carl-Lspn Carl-Lspn added the type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference. label Aug 9, 2021
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added stale and removed stale labels Oct 27, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2021

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 4, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
@bishwo-dahal
Copy link
Contributor

Surely will try to improve docs.
Feel free to share ideas ❤🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.
Projects
None yet
Development

No branches or pull requests

3 participants