When using MongoDB with Mongoskin in a Node.js webb app I can run .find() on a collection to fetch all its document. The result is a mongodb cursor. 
This cursor is then converted to an Array with the cursors .toArray() method. 
[
  {
    _id: "53ea101656cb0c0407306405",
    key: "value", 
    ...
  }, 
  {
    _id: "53ea101656cb0c0407306405",
    key: "value", 
    ...
  },
  ...
]
But is this a valid JSON output for a REST Api?... or should i convert the outer array to an object? Maybe it doesn't matter?
It is valid JSON, assuming you put quotes around your keys. REST does not specify the format that a JSON response must use, so do whatever is right for your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With