Skip to content

Adds _wrap-as-row_ feature for types. - #475

Merged
joente merged 13 commits into
mainfrom
rows
Nov 12, 2026
Merged

joente merged 13 commits into
mainfrom
rows

Conversation

@joente

@joente joente commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

Sometimes, especially for large lists, it would save much traffic if types are returned as simple lists instead of full objects.

For example:
Suppose we have .articles.wrap():

[
  {
    "id": 2,
    "name": "article number 1",
    "description": null,
    "price": 2.5
  },
  {
    "id": 3,
    "name": "article number 2",
    "description": null,
    "price": 5
  }
]

We could return the same as rows:

.articles.map(|a| [a.id(), a.name, a.description, a.price]);
[
  [2, "article number 1", null, 2.5],
  [3, "article number 2", null, 5]
]

The downside is that is is rather slow for a large list as first a new list must be created with all properties. When nested objects exist, we also loose an easy option to wrap those, except for wrapping each value indivisually.

Instead, this pull request adds the option to configure row for a type. If row is configured, the wrap instance of that type returns itself as an array.

For example:

mod_type('Article', 'row', ['id', 'name', 'description', 'price']);

Now, we can simply call:

.articles.map_wrap();
[
  [2, "article number 1", null, 2.5],
  [3, "article number 2", null, 5]
]

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Test row (new)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes

@joente joente self-assigned this Nov 11, 2026
@joente
joente merged commit 6c2832a into main Nov 12, 2026
1 check passed
@joente
joente deleted the rows branch November 12, 2026 11:44
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

Successfully merging this pull request may close these issues.

1 participant