Skip to content
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

Idea: schemaPopulated should support nested/arrayed object values #261

Closed
bppdddqqqq opened this issue Feb 10, 2021 · 0 comments
Closed

Comments

@bppdddqqqq
Copy link

bppdddqqqq commented Feb 10, 2021

Reason for this idea

Current schemaPopulated only allows to pre-populate two specific schema definitions

example:

{
    goodOne: {ref: "attachment", type: ObjectId},
    goodOnes: [{ref: "attachment", type: ObjectId}],
    badObject: {
        badOne: {ref: "attachment", type: ObjectId},
    },
    badArrays: [{
        badOne: {ref: "attachment", type: ObjectId}
    }]
}

goodOne and goodOnes will pass by setting schemaPopulated: ["goodOne", "goodOnes"], but the remaining two cannot be populated by limited implementation of requestPostPopulate function. The code in question is in lines 80-89, which only picks object items via bracket notation and not via some parser...

The reason why the current implementation can be insufficient is when if it were used with "Sortable Inputs" form component. Adding an attachment form item will end up with broken behaviour (this reflects badArrays case). For "badObject" this can be reflected in nested objects used for readability reasons...

Proposed modification

Expand the function to support other possible cases.

@bppdddqqqq bppdddqqqq changed the title Idea: schemaPopulated should support nested/arrayed index values Idea: schemaPopulated should support nested/arrayed object values Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants