Added product admin features
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { SQLDataSource } from 'datasource-sql';
|
||||
import { Market } from '../types/market-types';
|
||||
|
||||
const MINUTE = 60;
|
||||
|
||||
export class MarketAPI extends SQLDataSource {
|
||||
constructor(config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
async getMarketById(id: number): Promise<Market> {
|
||||
return this.knex
|
||||
.select('*')
|
||||
.from('markets')
|
||||
.where('id', id)
|
||||
.first()
|
||||
.cache(MINUTE * 5);
|
||||
}
|
||||
|
||||
async getMarketByName(name: string): Promise<Market> {
|
||||
return this.knex
|
||||
.select('*')
|
||||
.from('markets')
|
||||
.where('name', name)
|
||||
.first()
|
||||
.cache(MINUTE * 5);
|
||||
}
|
||||
|
||||
async getMarkets(): Promise<Array<Market>> {
|
||||
return this.knex
|
||||
.select('*')
|
||||
.from('markets')
|
||||
.cache(MINUTE * 5);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user