vasanthv / jsonbox

HTTP-based JSON storage.
https://jsonbox.io
MIT License
2.49k stars 173 forks source link

Route to get meta information of the box #48

Closed harlev closed 4 years ago

harlev commented 4 years ago

Based on requirements in issue https://github.com/vasanthv/jsonbox/issues/47

metadata items will be returned if _meta/ is appended to the beginning of a GET request for a box.
example: _meta/box_c6bd37b59afce59b5e2c The format of the result will be:

{ "count": 3, "createdOn": "2020-03-12T04:45:22.480Z", "updatedOn": "2020-03-12T06:23:26.000Z" }

Also added a basic test to verify the data coming back for a _meta request.

vasanthv commented 4 years ago

This change will give us the meta data of the queried records, not the meta data of the entire box. I was thinking of having a separate route like /_meta/BOX_ID which gives us the _count of all the records in the box with the _createdOn being the oldest record's created date and _lastUpdatedOn being the most recent updated date.

harlev commented 4 years ago

I can make it use the /_meta/BOX_ID route.
But as far as I can tell, what I implemented does give the requested result for the whole box

the _count of all the records in the box with the _createdOn being the oldest record's created date and _lastUpdatedOn being the most recent updated date.

harlev commented 4 years ago

@vasanthv made updates to match your suggestions and comments. Also cleaned up the helper function to be easier to read, and updated README The description at the top of the PR was updated to reflect the final implementation.