Skip to content

Latest commit

 

History

History
47 lines (41 loc) · 1.3 KB

File metadata and controls

47 lines (41 loc) · 1.3 KB


import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Typed maps (Record<string, T>)

A typed map is an object where each value is of the given type T.

For example, if your API returns a map of users with their ages, you could use a Record<string, number>:

```ts interface Database extends HybridObject { getAllUsers(): Record } ``` ```swift class HybridDatabase: HybridDatabaseSpec { func getAllUsers() -> Dictionary } ``` ```kotlin class HybridDatabase: HybridDatabaseSpec() { fun getAllUsers(): Map } ``` ```cpp class HybridDatabase: public HybridDatabaseSpec { std::unordered_map getAllUsers(); } ```

:::tip While typed maps are very efficient, Nitro cannot sufficiently optimize the object as keys are not known in advance. If possible, avoid typed maps and use arrays for unknown number of items, or strongly typed objects for known number of items instead. :::