idz: Expose some row mappers
This commit is contained in:
+16
-12
@@ -6,6 +6,21 @@ import { Profile } from "../model/profile";
|
||||
import { FacetRepository } from "../repo";
|
||||
import { Id } from "../../db";
|
||||
|
||||
export function _extractChara(row: any): Chara {
|
||||
return {
|
||||
gender: row.gender,
|
||||
field_02: row.field_02,
|
||||
field_04: row.field_04,
|
||||
field_06: row.field_06,
|
||||
field_08: row.field_08,
|
||||
field_0A: row.field_0A,
|
||||
field_0C: row.field_0C,
|
||||
field_0E: row.field_0E,
|
||||
title: row.title,
|
||||
background: row.background,
|
||||
};
|
||||
}
|
||||
|
||||
export class SqlCharaRepository implements FacetRepository<Chara> {
|
||||
constructor(private readonly _conn: ClientBase) {}
|
||||
|
||||
@@ -19,18 +34,7 @@ export class SqlCharaRepository implements FacetRepository<Chara> {
|
||||
const { rows } = await this._conn.query(loadSql);
|
||||
const row = rows[0];
|
||||
|
||||
return {
|
||||
gender: row.gender,
|
||||
field_02: row.field_02,
|
||||
field_04: row.field_04,
|
||||
field_06: row.field_06,
|
||||
field_08: row.field_08,
|
||||
field_0A: row.field_0A,
|
||||
field_0C: row.field_0C,
|
||||
field_0E: row.field_0E,
|
||||
title: row.title,
|
||||
background: row.background,
|
||||
};
|
||||
return _extractChara(row);
|
||||
}
|
||||
|
||||
async save(profileId: Id<Profile>, chara: Chara): Promise<void> {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ProfileRepository } from "../repo";
|
||||
import { generateId, Id } from "../../db";
|
||||
import { AimeId } from "../../model";
|
||||
|
||||
function _extractProfile(row: any): Profile {
|
||||
export function _extractProfile(row: any): Profile {
|
||||
return {
|
||||
aimeId: row.aime_id,
|
||||
name: row.name,
|
||||
|
||||
Reference in New Issue
Block a user