fremail / sequelize-nested-set

Library to store and manage nested set trees using Sequelize
MIT License
39 stars 10 forks source link

Attributes Reorder #36

Open ivan-ionin opened 1 year ago

codecov[bot] commented 1 year ago

Codecov Report

Base: 77.37% // Head: 76.49% // Decreases project coverage by -0.88% :warning:

Coverage data is based on head (a215cda) compared to base (a25d463). Patch coverage: 25.00% of modified lines in pull request are covered.

:exclamation: Current head a215cda differs from pull request most recent head 84c840f. Consider uploading reports for the commit 84c840f to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #36 +/- ## ========================================== - Coverage 77.37% 76.49% -0.88% ========================================== Files 2 2 Lines 495 502 +7 ========================================== + Hits 383 384 +1 - Misses 112 118 +6 ``` | [Impacted Files](https://codecov.io/gh/fremail/sequelize-nested-set/pull/36?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anton+Demushkin) | Coverage Δ | | |---|---|---| | [index.js](https://codecov.io/gh/fremail/sequelize-nested-set/pull/36?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anton+Demushkin#diff-aW5kZXguanM=) | `76.37% <25.00%> (-0.90%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anton+Demushkin). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anton+Demushkin)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

fremail commented 1 year ago

Hi, @ivan-ionin. Thank you for your PR!

Could you clarify the purpose of your changes please? To be honest, I didn't work with Sequelize the last few years, but AFAIK the attribute order doesn't matter.

ivan-ionin commented 1 year ago

When i create table i got attributes order like this:

-- left_key -- right_key -- level -- root -- id (primary) -- ...anotherMyCustomFields

I want to control it:

-- id (primary) -- left_key -- right_key -- level -- root -- ...anotherMyCustomFields

... because in my company very hard sql convention.

Sorry, i forgot add information to README.md in my pool request.

fremail commented 1 year ago

@ivan-ionin that makes sense. Thanks for explanation.

nsAfterField solves your particular issue, but doesn't provide full control over field order. How about nsFieldOrder array containing all fields in the desired order?

Example: nsFieldOrder = ['id', 'root', 'tag_name', 'left_key', 'level', 'right_key'];

That will allow you to reorder even internal nested set fields. And implementation of that option isn't hard -- a simple loop over that array.

It would be great to use nsOptions as other code does. And as you mentioned, it needs to add info about the new field into README.md.

Could you kindly do the updates?