Closed iand675 closed 7 years ago
I can confirm this needs to be improved. Specifically, the current mkDocument interface lacks of the ability to create an array that has 1 item. It looks like an easy fix. I'm going to fork this. I think 1 is better. I would be too lazy to type the 2nd implementation.
Ah, I see what you mean. These are good suggestions. I can make these changes soon. Alternatively, if you would like to submit a pull request, I'd be happy to review it so you can have the update sooner!
Thanks!
Hi, I'm experimenting a bit with ember-data, which incidentally inspired a lot of the design of the json-api spec. Whenever I return a 0-N query that happens to have one item, it is returned unwrapped (e.g. not in a JSON array). This causes ember-data to complain via assertion error that results from the query API should always be returned in an array.
I'd like to propose a few solutions:
mkDocument
(non-breaking) into something like: