Added product admin features

This commit is contained in:
Niklas Fondberg
2021-07-26 10:35:52 +02:00
committed by GitHub
parent 32adee1bf4
commit d17df41d86
38 changed files with 1613 additions and 381 deletions
+35
View File
@@ -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);
}
}