Closed drama-ostrich closed 4 years ago
Also if you want me to open individual issues and make PRs to the individual issues let me know
This is fantastic. Would you be able to add documentation surrounding anything that is not already documented? I will review this asap and we can get this merged. Thanks much
@tommybananas Hey yep I'll try to get some docs updates for you soon. I've been taking notes as I've been working with finale.
I realize there may not be a lot to say but if you could run your eyes over it and document what you think is important, that would be awesome! Thanks for the contributions
This fixes 3 Issues for
list.js
I've run into while dealing with included/associated models in a resource. I've tried to isolate these 3 problems in tests but the behavior changes based on if the resource hasoptions.subQuery = true/false
set and if the associations between models are one-to-many or many-to-many. Ideally I'm looking to be able to sort, search, and group by fields on included models at the same time.1. Group By breaks pagination
Current Version
If you use a group command (my test example is
context.options.group = ['users.id']
) then the sequelizefindAndCountAll()
method returns a list of grouped counts instead of one count number.Change
If
options.group
is set then split thefind
andcount
into two queries.2. Sort by field on associated model
Current Version
Sorting by a field on an included model doesn't work. Sequelize uses the wrong table name for the nested field when generating SQL
Change
I use a Sequelize.literal() in the sort if the field path has a period in it.
3. Search with "LIKE" on a associated resource
Current Version
If you want to search for a field on an associated resource you have the following options
?profile.nickname=name
Sequelize.Op.eq
operator, otherwise the search is picked up as astringOperator
inlist.js:115
and throws an error because the path to the included model isn't a sequelize.STRINGChange
I exclude search keys with a period in the serach for stringOperators to allow using
Sequelize.Op.like
in the search definition in the resourceNote: the field name in the search definition still requires the dollars around the field e.g.
$profile.nickname$