Sunday 16 July 2017

Noob question, sequelize

I am trying to use sequelize in a pretty simple setup, but I am making sure there isn't a better way to achieve what I want to achieve.models.prices.findOrCreate({ where: { price: product.price, sourceId: ???, productId: ??? } }); In this scenario both sourceId and productId are foreign keys. Both of these keys have to be queried. Currently I have a (what I feel) is a bootleg way of fixing this issue, I have multiple nested findOne queries. This looks ugly and doesn't feel elegant.So, my question is: Is there a better way to access the sourceId and productId without nesting a ton of these queries?productId would need a query searching for SKU and retrieving ID in model productssourceId would need a query searching for a string and retrieve the ID in model sourcesSorry if this seems like a dumb question, I just come from a Django background. This is usually pretty basic/built-in stuff, making sure I am not missing something.

Submitted July 16, 2017 at 09:50AM by Miles360x

No comments:

Post a Comment