You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.8 KiB
58 lines
1.8 KiB
2 years ago
|
import {TransactType} from "./index";
|
||
|
|
||
|
export interface PronounData {
|
||
|
id: string
|
||
|
default_marker: string
|
||
|
name: string
|
||
|
display_order: number
|
||
|
use_plural: boolean
|
||
|
subjective: string
|
||
|
adjective: string
|
||
|
possessive: string
|
||
|
reflexive: string
|
||
|
objective: string
|
||
|
}
|
||
|
|
||
|
export interface GenderMarkerData {
|
||
|
emoji: string
|
||
|
default_name: string
|
||
|
display_order: number
|
||
|
}
|
||
|
|
||
|
export interface GenderTablesData {
|
||
|
pronouns: PronounData[]
|
||
|
markers: GenderMarkerData[]
|
||
|
}
|
||
|
|
||
2 years ago
|
export interface GenderTable {
|
||
2 years ago
|
getPronounsAndMarkers(): Promise<GenderTablesData>
|
||
|
}
|
||
|
|
||
2 years ago
|
export class GenderTablesImpl implements GenderTable {
|
||
2 years ago
|
private readonly _transact: TransactType
|
||
|
|
||
|
constructor({transact}: { transact: TransactType }) {
|
||
|
this._transact = transact
|
||
|
}
|
||
|
|
||
|
async getPronounsAndMarkers(): Promise<GenderTablesData> {
|
||
|
const result: GenderTablesData = {
|
||
|
pronouns: [],
|
||
|
markers: [],
|
||
|
}
|
||
|
await this._transact({
|
||
|
readonly: true,
|
||
|
async transaction(query) {
|
||
|
const pronouns = await query<{id: string, default_marker: string, name: string, display_order: number, use_plural: boolean, subjective: string, adjective: string, possessive: string, reflexive: string, objective: string}>(
|
||
|
`SELECT id, default_marker, name, display_order, use_plural, subjective, adjective, possessive, reflexive, objective FROM pronouns`
|
||
|
)
|
||
|
const markers = await query<{emoji: string, default_name: string, display_order: number}>(
|
||
|
`SELECT emoji, default_name, display_order FROM gender_markers`
|
||
|
)
|
||
|
result.pronouns = pronouns.rows
|
||
|
result.markers = markers.rows
|
||
|
}
|
||
|
})
|
||
|
return result
|
||
|
}
|
||
|
}
|