json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Many-to-one relationship support via _embed (fixes #366)

Open lukzas opened this issue 5 years ago • 1 comments

Added support for an array of ids in _embed function and some tests. Didn't touch _expand as it's supposed to be fixed by PR #648.

lukzas avatar Aug 10 '19 18:08 lukzas

This actually fails if the first index in the data to be embedded doesn't contain a foreign key to the resource. I made some changes here that fixes this. Not sure what the desired behavior is for this overall, but for me it seemed very counter intuitive, and not all data is going to be normalized in db.json. I'm creating an app now where I'm creating these relationships on the fly, I don't think I should have to add the foreign key to the first index of all the embedded data I want.

jpstone avatar Sep 19 '19 16:09 jpstone