Skip to content

Commit

Permalink
Added query parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
grafitto committed Nov 23, 2018
1 parent d33a464 commit 7106108
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/functions/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
AppData,
Tag,
IData,
PersistedAppData
PersistedAppData,
QueryParams
} from "../types";
import { requests } from "../requests";
import { ServiceBase } from "../service-base";
Expand Down Expand Up @@ -44,7 +45,7 @@ export class Data extends ServiceBase implements IData{
* @param query (Optional) query
* @returns Promise<PersistedEntityData[]>
*/
public async getEntities(query?: any): Promise<PersistedEntityData[]> {
public async getEntities(query?: QueryParams): Promise<PersistedEntityData[]> {
return await this.internalRequest(requests.data.getEntities, query);
}

Expand Down
17 changes: 16 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ export interface MenuItem {
default?: boolean;
}

export interface QueryMatch {
[fieldOrOp: string]: any;
}

export interface QueryParams {
[key: string]: any;
query?: QueryMatch;
limit?: number;
skip?: number;
sort?: {
[field: string]: number;
};
tags?: string[];
}

export interface FileParams {
name: string;
public: boolean;
Expand Down Expand Up @@ -109,7 +124,7 @@ interface HasTimestamps {
export interface IData {
createEntity(entity: EntityData): Promise<PersistedEntityData>;
project(): Promise<Project>;
getEntities(query?: any): Promise<PersistedEntityData[]>;
getEntities(query?: QueryParams): Promise<PersistedEntityData[]>;
getEntityById(id: string): Promise<PersistedEntityData>;
addTagsToEntity(params: TagsParams): Promise<PersistedEntityData>;
removeTagsFromEntity(params: TagsParams): Promise<PersistedEntityData>;
Expand Down

0 comments on commit 7106108

Please sign in to comment.