style: formater sources et scripts (prettier)
This commit is contained in:
1 parent
01337ef480
commit
77ac6e0e21
8 files changed
+31
-18
No files matched your search
@@ -47,17 +47,25 @@ export class MysqlCardRepository implements CardRepository {
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<Card | null> {
|
||||
const [rows] = await this.pool.query<CardRow[]>(`SELECT ${FIELDS.join(', ')} FROM cards WHERE id = ?`, [id])
|
||||
const [rows] = await this.pool.query<CardRow[]>(
|
||||
`SELECT ${FIELDS.join(', ')} FROM cards WHERE id = ?`,
|
||||
[id],
|
||||
)
|
||||
return rows[0] ? this.mapRow(rows[0]) : null
|
||||
}
|
||||
|
||||
async create(input: CardInput): Promise<Card> {
|
||||
const id = crypto.randomUUID()
|
||||
const now = new Date()
|
||||
await this.pool.query(
|
||||
`INSERT INTO cards (${FIELDS.join(', ')}) VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[id, input.question, input.response, input.theme, JSON.stringify(input.tags ?? []), now, now],
|
||||
)
|
||||
await this.pool.query(`INSERT INTO cards (${FIELDS.join(', ')}) VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
||||
id,
|
||||
input.question,
|
||||
input.response,
|
||||
input.theme,
|
||||
JSON.stringify(input.tags ?? []),
|
||||
now,
|
||||
now,
|
||||
])
|
||||
return {
|
||||
id,
|
||||
question: input.question,
|
||||
@@ -104,7 +112,9 @@ export class MysqlCardRepository implements CardRepository {
|
||||
}
|
||||
|
||||
async findRandom(): Promise<Card | null> {
|
||||
const [rows] = await this.pool.query<CardRow[]>(`SELECT ${FIELDS.join(', ')} FROM cards ORDER BY RAND() LIMIT 1`)
|
||||
const [rows] = await this.pool.query<CardRow[]>(
|
||||
`SELECT ${FIELDS.join(', ')} FROM cards ORDER BY RAND() LIMIT 1`,
|
||||
)
|
||||
return rows[0] ? this.mapRow(rows[0]) : null
|
||||
}
|
||||
|
||||
@@ -117,7 +127,9 @@ export class MysqlCardRepository implements CardRepository {
|
||||
}
|
||||
|
||||
async findThemes(): Promise<string[]> {
|
||||
const [rows] = await this.pool.query<RowDataPacket[]>('SELECT DISTINCT theme FROM cards ORDER BY theme')
|
||||
const [rows] = await this.pool.query<RowDataPacket[]>(
|
||||
'SELECT DISTINCT theme FROM cards ORDER BY theme',
|
||||
)
|
||||
return rows.map((row) => row.theme as string)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user