egg_server/db/log/index.ts

35 lines
602 B
TypeScript

import { RecordModel } from "pocketbase"
import { managePbError } from "../../utils/pbTools"
import pbClient from "../pbClient"
const DB_NAME = "messageLog"
export interface Log {
apiKey: string
groupId?: string
receiveId?: string
receiveIdType?: string
msgType: string
content: string
finalContent?: string
sendResult?: any
error?: string
}
export type LogModel = Log & RecordModel
/**
* 创建一条日志
* @param log
* @returns
*/
const create = (log: Log) =>
managePbError(() => pbClient.collection(DB_NAME).create(log))
const log = {
create,
}
export default log