stackvana / hook.io

Open-Source Microservice Hosting Platform
https://hook.io
Other
1.27k stars 119 forks source link

Using the Datastore [NodeJS] #301

Closed gayanhewa closed 6 years ago

gayanhewa commented 6 years ago

I am currently trying to use the service that uses the data store.

Is there a global variable hook that gives me access to the store?

Or do I always have to follow the pattern of replacing

module['exports'] = function myService(req, res, next) {

with

module['exports'] = function myService(hook) {

And access the data store via hook.datastore?

When I opt to do the latter, some of the parameters submitted are not available trough hook.req.params

Marak commented 6 years ago

We made an update recently to support function (req, res, next) signatures.

The req object should have all the same expected properties as the hook object.

hook also contains hook.req and hook.res. They should all be equivalent.

Marak commented 6 years ago

hook.req.params is not equivalent to hook.params. Those are two separate scopes.

Marak commented 6 years ago

Documentation and example usage for the datastore can be found here: http://hook.io/datastore

gayanhewa commented 6 years ago

Thanks @Marak , I couldn't find a way to do a getAll documents. Is this not supported?

Marak commented 6 years ago

For performance reasons, there is no way to get all documents.