feat(database): add event log repository
Refs: #93 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 file changed
+13
@@ -0,0 +1,13 @@
|
||||
import { getDatabase } from '../index.js';
|
||||
|
||||
export function logEvent({ guildId = null, type, actorId = null, payload = null }) {
|
||||
getDatabase()
|
||||
.prepare('INSERT INTO event_logs (guild_id, type, actor_id, payload) VALUES (?, ?, ?, ?)')
|
||||
.run(guildId, type, actorId, payload ? JSON.stringify(payload) : null);
|
||||
}
|
||||
|
||||
export function purgeEventsOlderThan(days) {
|
||||
return getDatabase()
|
||||
.prepare("DELETE FROM event_logs WHERE created_at < datetime('now', ?)")
|
||||
.run(`-${days} days`).changes;
|
||||
}
|
||||
Reference in new issue
Block a user