retro/apitizer

Working with nested `id` field.

gxxcastillo opened this issue · 2 comments

I've got a schema where the id field is nested inside of another object.

ex:

{
     data: {
          id: 123
     }
}

Because of this I have been unable to get apitizer to generate the /entity/{id} url. Is there some way to let apitizer know that the id property is nested inside of another object?

Note, the /entity url works fine and an /entity/{id} url works if move the id to the top level in my schema.

If you need to customize that kind of behavior the easiest way would be to override the store.findOne method. Take a look here https://github.com/retro/apitizer/blob/master/lib/api.js#L14 to see how it's implemented.

Then you can pass your custom API implementation to the schema store (https://github.com/retro/apitizer/blob/master/apitizer.js#L37 and https://github.com/retro/apitizer/blob/master/tests/api_test.js#L58).

That did it, thanks!