feat: add findOneAnotherKey
This commit is contained in:
parent
e217fb29fc
commit
4c65794b6c
5 changed files with 43 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "muffin-ai-arujak",
|
||||
"version": "2.0.0-75-oreo",
|
||||
"version": "2.0.0-77-oreo",
|
||||
"main": "dist/index.js",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -58,4 +58,15 @@ export class LearnTable implements BaseTable<LearnData, string> {
|
|||
await db.execute('DELETE FROM learn WHERE command = ?;', [key])
|
||||
})
|
||||
}
|
||||
|
||||
public async findOneAnotherKey(
|
||||
key: 'command' | 'result' | 'user_id' | 'created_at',
|
||||
data: any,
|
||||
): Promise<LearnData[]> {
|
||||
const [rows] = await this._database.execute<LearnData[]>(
|
||||
'SELECT * FROM learn WHERE ? = ?;',
|
||||
[key, data],
|
||||
)
|
||||
return rows
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,15 @@ export class NSFWContentTable implements BaseTable<NSFWData, number> {
|
|||
await db.execute('DELETE FROM nsfw_content WHERE id = ?;', [key])
|
||||
})
|
||||
}
|
||||
|
||||
public async findOneAnotherKey(
|
||||
key: 'id' | 'text' | 'persona' | 'created_at',
|
||||
data: any,
|
||||
): Promise<NSFWData[]> {
|
||||
const [rows] = await this._database.execute<NSFWData[]>(
|
||||
'SELECT * FROM nsfw_content WHERE ? = ?;',
|
||||
[key, data],
|
||||
)
|
||||
return rows
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,4 +55,23 @@ export class StatementTable implements BaseTable<ResponseData, number> {
|
|||
await db.execute('DELETE FROM statement WHERE id = ?;', [key])
|
||||
})
|
||||
}
|
||||
|
||||
public async findOneAnotherKey(
|
||||
key:
|
||||
| 'id'
|
||||
| 'text'
|
||||
| 'persona'
|
||||
| 'created_at'
|
||||
| 'search_text'
|
||||
| 'conversation'
|
||||
| 'in_response_to'
|
||||
| 'search_in_response_to',
|
||||
data: any,
|
||||
): Promise<ResponseData[]> {
|
||||
const [rows] = await this._database.execute<ResponseData[]>(
|
||||
'SELECT * FROM statement WHERE ? = ?;',
|
||||
[key, data],
|
||||
)
|
||||
return rows
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,5 @@ export interface BaseTable<T, V> {
|
|||
insert(data: any): Promise<void>
|
||||
update(data: any): Promise<void>
|
||||
delete(key: V): Promise<void>
|
||||
findOneAnotherKey(key: string, data: any): Promise<T[]>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue