-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
-
-
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
[Feature] Add findByPks convenience method #11297
Comments
@papb I was taking a look in this feature and should we create another method or can we let |
@fboechats Hello. I think it's better to create a new method, |
@papb Sure, I will try to make a PR with this feature |
@papb Can I get some help on how to debug the method a created?? Tried using the vscode debug tool, but didn't work as expected. |
@fboechats It usually works for me, I place some breakpoints and navigate through it. Can you be more specific? |
@papb Sure, it got some errors. I guess it's because I'm running mysql on docker. So now I'm trying to use Mocha tests to kind of debug. |
@fboechats To work on this feature, which is not dialect-specific, I think you should just use sqlite instead, it is so much easier... const { Sequelize } = require("sequelize");
const sequelize = new Sequelize("sqlite::memory:");
// do your work |
@papb I opened a PR with some initial idea and simple tests. |
Hi @fboechats if you're still trying to debug the test, you can do it with |
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. 🙂 |
@tapiwakundi Sure! Feel free to give it a try |
A common thing we do is searching for model that match a given id set. This is not that hard with the following clause:
Model.findAll({where: {id: {[Op.in]: [1, 2, 3]}}})
, however it might be easier if afindByPks
method was added so that one would doModel.findByPks([1,2,3])
and/orModel.findByPks(1,2,3)
.Rails has this: https://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find
TypeORM has this: https://typeorm.io/#/entity-manager-api Search for findByIds
I think if this will be added, we should investigate what other convenience methods could be added. For example, there is an open issue about adding
exists
: #10187The text was updated successfully, but these errors were encountered: