Add product
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { SQLDataSource } from 'datasource-sql';
|
||||
import { camelcase } from 'stringcase';
|
||||
import { Address, ContactInformation, Order, OrderRow } from './order-types';
|
||||
import {
|
||||
Address,
|
||||
ContactInformation,
|
||||
Market,
|
||||
Order,
|
||||
OrderRow,
|
||||
} from './order-types';
|
||||
import { Maybe } from './types';
|
||||
|
||||
const MINUTE = 60;
|
||||
@@ -9,6 +15,24 @@ export class OrderAPI extends SQLDataSource {
|
||||
super(config);
|
||||
}
|
||||
|
||||
async getMarketById(id: number): Promise<Market> {
|
||||
return await this.knex
|
||||
.select('*')
|
||||
.from('markets')
|
||||
.where('id', id)
|
||||
.first()
|
||||
.cache(MINUTE);
|
||||
}
|
||||
|
||||
async getMarketByName(name: string): Promise<Market> {
|
||||
return await this.knex
|
||||
.select('*')
|
||||
.from('markets')
|
||||
.where('name', name)
|
||||
.first()
|
||||
.cache(MINUTE);
|
||||
}
|
||||
|
||||
async getAddress(addressId: number): Promise<Maybe<Address>> {
|
||||
const row = await this.knex
|
||||
.select('*')
|
||||
@@ -103,7 +127,6 @@ export class OrderAPI extends SQLDataSource {
|
||||
}
|
||||
const orderRow = details.reduce((obj, item) => {
|
||||
obj[camelcase(fields[item.fieldid])] = item.value;
|
||||
obj['insertedDate'] = item.inserted;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
@@ -120,6 +143,7 @@ export class OrderAPI extends SQLDataSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* row
|
||||
{
|
||||
printId: '73963',
|
||||
inserted: 2021-02-04T10:11:41.093Z,
|
||||
|
||||
Reference in New Issue
Block a user