fix: MessageManager 建表失敗
This commit is contained in:
@@ -27,12 +27,12 @@ export default class MessagesManager {
|
|||||||
CREATE TABLE IF NOT EXISTS ${this.getTableName()} (
|
CREATE TABLE IF NOT EXISTS ${this.getTableName()} (
|
||||||
/* 序号, MessageId */ id INTEGER PRIMARY KEY AUTOINCREMENT,
|
/* 序号, MessageId */ id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
/* 消息文本 */ text TEXT NOT NULL,
|
/* 消息文本 */ text TEXT NOT NULL,
|
||||||
/* 发送者 */ user_id TEXT NOT NULL,
|
/* 发送者 */ user_id TEXT NOT NULL
|
||||||
);
|
);
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
protected getTableName() {
|
protected getTableName() {
|
||||||
return `messages_${this.chat.bean.id}`
|
return `messages_${this.chat.bean.id}`.replaceAll('-', '_')
|
||||||
}
|
}
|
||||||
addMessage({
|
addMessage({
|
||||||
text,
|
text,
|
||||||
@@ -41,13 +41,13 @@ export default class MessagesManager {
|
|||||||
text: string,
|
text: string,
|
||||||
user_id?: string
|
user_id?: string
|
||||||
}) {
|
}) {
|
||||||
MessagesManager.database.prepare(`INSERT INTO ${this.getTableName()} (
|
return MessagesManager.database.prepare(`INSERT INTO ${this.getTableName()} (
|
||||||
text,
|
text,
|
||||||
user_id
|
user_id
|
||||||
) VALUES (?, ?);`).run(
|
) VALUES (?, ?);`).run(
|
||||||
text,
|
text,
|
||||||
user_id || null
|
user_id || null
|
||||||
)
|
).lastInsertRowid
|
||||||
}
|
}
|
||||||
addSystemMessage(text: string) {
|
addSystemMessage(text: string) {
|
||||||
this.addMessage({
|
this.addMessage({
|
||||||
|
|||||||
Reference in New Issue
Block a user