Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b21a0bdae |
@@ -10,6 +10,6 @@ export async function loadGarage(
|
||||
|
||||
return {
|
||||
type: "load_garage_res",
|
||||
cars: await w.car().loadAllCars(profileId),
|
||||
cars: await w.car().loadCars(profileId, 10, req.fetchOffset),
|
||||
};
|
||||
}
|
||||
|
||||
+5
-1
@@ -11,7 +11,11 @@ export type TeamSpec = Subtract<
|
||||
export interface CarRepository {
|
||||
countCars(profileId: Id<Model.Profile>): Promise<number>;
|
||||
|
||||
loadAllCars(profileId: Id<Model.Profile>): Promise<Model.Car[]>;
|
||||
loadCars(
|
||||
profileId: Id<Model.Profile>,
|
||||
limit: number,
|
||||
offset: number
|
||||
): Promise<Model.Car[]>;
|
||||
|
||||
loadSelectedCar(profileId: Id<Model.Profile>): Promise<Model.Car>;
|
||||
|
||||
|
||||
+9
-2
@@ -40,11 +40,18 @@ export class SqlCarRepository implements CarRepository {
|
||||
return parseInt(row!.result);
|
||||
}
|
||||
|
||||
async loadAllCars(profileId: Id<Profile>): Promise<Car[]> {
|
||||
async loadCars(
|
||||
profileId: Id<Profile>,
|
||||
limit: number,
|
||||
offset: number
|
||||
): Promise<Car[]> {
|
||||
const loadSql = sql
|
||||
.select("c.*")
|
||||
.from("idz_car c")
|
||||
.where("c.profile_id", profileId);
|
||||
.where("c.profile_id", profileId)
|
||||
.orderBy("selector asc")
|
||||
.limit(limit)
|
||||
.offset(offset);
|
||||
|
||||
const rows = await this._txn.fetchRows(loadSql);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ declare module "sql-bricks-postgres" {
|
||||
}
|
||||
|
||||
interface LimitClause extends sql.SelectStatement {
|
||||
offset(value: number): sql.Statement;
|
||||
offset(value: number): sql.SelectStatement;
|
||||
}
|
||||
|
||||
export interface PgInsertStatement extends sql.InsertStatement {
|
||||
|
||||
Reference in New Issue
Block a user