Skip to content

Commit

Permalink
feat(database): pass through additional query options to model methods
Browse files Browse the repository at this point in the history
closes #329
  • Loading branch information
acburdine committed Jun 13, 2017
1 parent abf1367 commit abcefb0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/data/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import Model from './model';

export default class DatabaseService extends Service {

find(modelType: string, id: any): Promise<Model|null> {
find(modelType: string, id: any, options?: any): Promise<Model|null> {
let ModelClass = <typeof Model>this.container.factoryFor(`model:${ modelType }`).class;
return ModelClass.find(this.container, id);
return ModelClass.find(this.container, id, options);
}

queryOne(modelType: string, query: any): Promise<Model|null> {
queryOne(modelType: string, query: any, options?: any): Promise<Model|null> {
let ModelClass = <typeof Model>this.container.factoryFor(`model:${ modelType }`).class;
return ModelClass.queryOne(this.container, query);
return ModelClass.queryOne(this.container, query, options);
}

query(modelType: string, query: any): Promise<Model[]> {
query(modelType: string, query: any, options?: any): Promise<Model[]> {
let ModelClass = <typeof Model>this.container.factoryFor(`model:${ modelType }`).class;
return ModelClass.query(this.container, query);
return ModelClass.query(this.container, query, options);
}

all(modelType: string): Promise<Model[]> {
all(modelType: string, options?: any): Promise<Model[]> {
let ModelClass = <typeof Model>this.container.factoryFor(`model:${ modelType }`).class;
return ModelClass.all(this.container);
return ModelClass.all(this.container, options);
}

create(modelType: string, data: any): Model {
return this.container.factoryFor(`model:${ modelType }`).create(this.container, data);
create(modelType: string, data: any, options?: any): Model {
return this.container.factoryFor(`model:${ modelType }`).create(this.container, data, options);
}

}

0 comments on commit abcefb0

Please sign in to comment.