UNPKG

mir-client

Version:
163 lines (95 loc) 3.81 kB
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents - [CreateGetterFactory][1] - [GetterFactory][2] - [QueryBuilder][3] - [previous][4] - [first][5] - [last][6] - [send][7] - [projection][8] - [sort][9] - [filter][10] - [page][11] - [limit][12] - [next][13] ## CreateGetterFactory **Parameters** - `axios` **[Object][14]** Initialized Axios instance. Returns **[GetterFactory][15]** A factory function that accepts a Mir API resource name ## GetterFactory Type: [function][16] **Parameters** - `resource` **[string][17]** Initialized Axios instance. Returns **[QueryBuilder][18]** Object that acts as a query builder for Mir requests ## QueryBuilder Type: [Object][14] **Properties** - `params` **[Object][14]** Stores parameters for the request - `headers` **[Object][14]** Stores headers for the request - `projection` **[function][16]** Updates params object with projection configuration - `sort` **[function][16]** Updates params object with sorting configuration - `filter` **[function][16]** Updates params object with filter configuration - `page` **[function][16]** Updates params object with page configuration - `limit` **[function][16]** Updates params object with maximum result count - `next` **[function][16]** Send a request for the next page - `previous` **[function][16]** Send a request for the previous page - `first` **[function][16]** Send a request for the first page - `last` **[function][16]** Send a request for the last page - `send` **[function][16]** Send a request with the current stored headers and params configurations ### previous Returns **[Promise][19]** Axios promise ### first Returns **[Promise][19]** Axios promise ### last Returns **[Promise][19]** Axios promise ### send **Parameters** - `hook` **[function][16]** TODO: Not implemented, will just contain a function to alter returned results Returns **[Promise][19]** Axios promise ## projection **Parameters** - `attribute` **[string][17]** Name of the resource attribute to apply projection - `bool` **[boolean][20]** Indicates whether the attribute should appear in the results ## sort **Parameters** - `attribute` **[string][17]** Name of the resource attribute to sort by - `value` **[string][17]** Either '+' or '-' for ascending or descending ## filter - **See: [Eve Filtering][21]** - **See: [MongoDB Queries][22]** **Parameters** - `attribute` **[string][17]** Name of the resource attribute to filter by - `value` **[Object][14]** Object defining Eve filters ## page **Parameters** - `value` **[number][23]** A page number ## limit **Parameters** - `value` **[number][23]** Maximum number of results to return in the request ## next Send GET for the next page of results Returns **[Promise][19]** Axios promise [1]: #creategetterfactory [2]: #getterfactory [3]: #querybuilder [4]: #previous [5]: #first [6]: #last [7]: #send [8]: #projection [9]: #sort [10]: #filter [11]: #page [12]: #limit [13]: #next [14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [15]: #getterfactory [16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function [17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [18]: #querybuilder [19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise [20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [21]: http://python-eve.org/features.html#filtering [22]: https://docs.mongodb.com/v3.2/reference/operator/query/ [23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number