Skip to content

nested create through REST #1196

Description

@mkeremguc

either i couldn't find in documentation or this is a feature request:

Country hasMany Cities
City belongsTo Country

is it possible to create/update models through REST like:

POST api/country
{
 "name": "England",
 "cities": [{"name":"London"}, {"name":"Manchester"}]
}

that would create the country and then create 2 cities with the names accordingly and set the hasmany/belongsto relation between.
and even more:

POST api/country
{
 "name": "England",
 "cities": [{"id":1}, {"id":2}]
}

that would create the country and set the relation accordingly with the specified ids.

I tried this without any success and i wonder if this is already possible with a different way. . i'm new to loopback and trying to discover the capabilities. sorry if this is a duplicate or already implemented feature. i would really want to know if so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions