mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor(server): split HistoryModel from DocModel (#10604)
This commit is contained in:
@@ -171,14 +171,14 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
|
||||
docId: string,
|
||||
query: HistoryFilter
|
||||
) {
|
||||
return await this.models.doc.findHistories(workspaceId, docId, {
|
||||
return await this.models.history.findMany(workspaceId, docId, {
|
||||
before: query.before,
|
||||
take: query.limit,
|
||||
});
|
||||
}
|
||||
|
||||
async getDocHistory(workspaceId: string, docId: string, timestamp: number) {
|
||||
const history = await this.models.doc.getHistory(
|
||||
const history = await this.models.history.get(
|
||||
workspaceId,
|
||||
docId,
|
||||
timestamp
|
||||
@@ -282,7 +282,7 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
|
||||
}
|
||||
|
||||
try {
|
||||
await this.models.doc.createHistory(
|
||||
await this.models.history.create(
|
||||
{
|
||||
spaceId: snapshot.spaceId,
|
||||
docId: snapshot.docId,
|
||||
@@ -372,7 +372,7 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
|
||||
}
|
||||
|
||||
protected async lastDocHistory(workspaceId: string, id: string) {
|
||||
return this.models.doc.getLatestHistory(workspaceId, id);
|
||||
return this.models.history.getLatest(workspaceId, id);
|
||||
}
|
||||
|
||||
// for auto merging
|
||||
|
||||
@@ -32,7 +32,7 @@ export class DocStorageCronJob {
|
||||
|
||||
@OnJob('nightly.cleanExpiredHistories')
|
||||
async cleanExpiredHistories() {
|
||||
await this.models.doc.deleteExpiredHistories();
|
||||
await this.models.history.cleanExpired();
|
||||
}
|
||||
|
||||
@OnEvent('user.deleted')
|
||||
|
||||
Reference in New Issue
Block a user