-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
perf: flattenFields
sanitized collection/global property, remove deep copying in validateQueryPaths
#9299
base: main
Are you sure you want to change the base?
Conversation
…ep copying for each constraint in `validateQueryPaths`
2aea43e
to
6d3503f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Kind of a pain to change all the names, but I think it would be good to make the name change.
What do you think?
flattenFields: FlattenField[] | ||
} & MarkRequired<TabAsField, 'name'> | ||
|
||
export type FlattenField = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name for this type is slightly off for me which hurts readability a bit. I would name it FlattenedField
and change that on these other types too. FlattenedArrayField
is the result of flattenFields()
the function.
* Fields in the database schema structure | ||
* Rows / collapsible / tabs w/o name `fields` merged to top, UIs are excluded | ||
*/ | ||
flattenFields: FlattenField[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be named flattenedFields
to be more clear. flattenFields
sounds like a function.
What?
Improves querying performance of the Local API, reduces copying overhead
How?
Adds
flattenFields
property for sanitized collection/global config which contains fields in database schema structure.For example, It removes rows / collapsible / unnamed tabs and merges them to the parent
fields
, ignores UI fields, named tabs are added astype: 'tab'
.This simplifies code in places like Drizzle
transform/traverseFields
. Also, now we can avoid callingflattenTopLevelFields
which adds some overhead and usecollection.flattenFields
/field.flattenFields
.Removes this deep copying for each
where
query constraintpayload/packages/payload/src/database/queryValidation/validateQueryPaths.ts
Lines 69 to 73 in 58ac784
Benchmark in
relationships/int.spec.ts
:Before:
After: