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

Feature: Support list type for a field #63

Closed
chuck-alt-delete opened this issue Mar 7, 2023 · 1 comment · Fixed by #85
Closed

Feature: Support list type for a field #63

chuck-alt-delete opened this issue Mar 7, 2023 · 1 comment · Fixed by #85
Labels
enhancement New feature or request

Comments

@chuck-alt-delete
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Datagen doesn’t yet support fields that are lists. I want do to a thing where each order has a list of item ids, then have the item list be the parent field and items.id be the child field.

As a stopgap, I suppose I could make orders an append-only stream with individual item ids instead of a list. I would limit the key space of the order ids to get several items per order. Then I can group by order id and aggregate the item ids into a list

Describe the solution you'd like

I think we would add a case to the record generation function to handle Array type (currently only handles Object and primitive types). There should be one faker method inside the list, and then we generate a random number of elements where the values are generated from the faker method.

For relationships, if the parent field is a list, we would iterate over the list to generate the child records.

@chuck-alt-delete chuck-alt-delete added the enhancement New feature or request label Mar 7, 2023
@chuck-alt-delete chuck-alt-delete mentioned this issue Mar 7, 2023
6 tasks
@chuck-alt-delete
Copy link
Contributor Author

As a part of this issue, I would like us to support things like this:

[
    {
        "_meta": {
            "key": "id",
            "topic": "test"
        },
        "id": "datatype.uuid",
        "arr": "helpers.uniqueArray(faker.random.word, 50)"
    }
]

The Faker API has a method called helpers.uniqueArray which can take a function as an input and use that function to generate an array of unique elements. This would be helpful, for example, creating an array of fake product names or ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant