Eve - luftsport/nlf-client GitHub Wiki
Eve Query Syntax
The ApiOptionsInterface
parameter query
follows Eve's query syntax which is very similar to raw MongoDb queries.
export interface QueryInterface {
where?: any; //string mongodb query
max_results?: number; //number
page?: number; //number
sort?: any; //string or array? [{key: 1}] or ["-key", "key2", ...]
aggregate?: any; //string
projection?: any;
}
Where
Example: where: {id: 3232}
Max Results - limit returned rows
max_results: 10
Page - Pagination
page: 2
Combine with max_results
Sort
sort: [{_created: -1}]
Note the array of object notation
Aggregate
Utilize the MongoDb aggregation framework.
If any parameters, use the aggregate
keyword to supply parameters.
aggregate: {"$value": 10}
Note that if aggregation pipeline returns an array of items regardsless of only a single item is returned (_items[0]
). Metadata is not supplied in aggregation resources
Projection
Control which fields should be returned (1) or not (-1)
projection: {id: 1, firstname: 1, lastname: 1, _etag: -1}
Only firstame
projection: {firstname: 1}
Eve meta data will always be returned if not explicit set as -1.
Eve interfaces
export interface ApiEveLink {
href: string;
title: string;
}
export interface ApiEveLinks {
parent: ApiEveLink;
self: ApiEveLink;
collection: ApiEveLink;
}
export interface ApiEveMeta {
page: number;
max_results: number;
total: number;
}
export interface ApiEveBaseList {
_meta?: ApiEveMeta;
_links?: ApiEveLinks;
}
export interface ApiEveList extends ApiEveBaseList {
_items: ApiEveItem[];
}
export interface ApiEveBaseItem {
_version?: number;
_etag?: string;
_created?: Date;
_id?: string;
_latest_version?: number;
_updated?: Date;
_links?: ApiEveLinks;
}
export interface ApiEveItem {
id?: string;
_id: string;
}