jaystack / odata-v4-server

With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.
https://jaystack.com/products/jaystack-odata-v4-server/
75 stars 55 forks source link

How can I use generic query string parameters for apikeys #27

Closed mastasky closed 6 years ago

mastasky commented 6 years ago

Hi,

I have a large recordset that holds records owned by different users. Now I want to enable them to use OData to query their (!) data only.

My ideas were like this:

  1. server/xyz/Records (this would get all records for the user with apikey xyz)
  2. server/Records?apikey=xyz

Option 1 should be easy enough, as xyz is in the context, but I can't access it from my "find" GET function. That one only has query.

Option 2 throws an error.

How can I do this? Thanks for your help.

mastasky commented 6 years ago

Most amazingly I could just use this call

@odata.GET
async find(@odata.context context, @odata.query query: ODataQuery): Promise<Record[]> {
...
}

The key is then to USE query and context in the code. If you don't, the objects are empty.