resgateio / resgate

A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.
https://resgate.io
MIT License
685 stars 67 forks source link

Support for primitive items in collections #3

Closed jirenius closed 6 years ago

jirenius commented 6 years ago

Issue

Collection currectly only supports model items.
In case you wish for a collection of string values, you currently have to wrap them in objects.

Example response to get.imgService.img.42.tags:

[
    "tagService.tag.10",
    "tagService.tag.12",
    "tagService.tag.15"
]

Example response to get.tagService.tag.10:

{
    "name": "nature"
}

Suggested solution

On a collection get request, the array should contain the same type of value format as used for model properties, instead of sending an array of rid strings. Model items should instead be a resource link object:

[
    "text",
    123,
    {"rid":"serviceName.model.42"}
]

Example response to get.imgService.img.42.tags:

[
    "nature",
    "forest",
    "morning"
]

This would also affect the event data structure of collection add/remove events.

jirenius commented 6 years ago

Completed in https://github.com/jirenius/resgate/pull/10 https://github.com/jirenius/resclient/pull/2