mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 04:26:23 +08:00
feat(nbstore): add blob sync storage (#10752)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { share } from '../../connection';
|
||||
import { BlobSyncStorageBase } from '../../storage';
|
||||
import { NativeDBConnection, type SqliteNativeDBOptions } from './db';
|
||||
|
||||
export class SqliteBlobSyncStorage extends BlobSyncStorageBase {
|
||||
static readonly identifier = 'SqliteBlobSyncStorage';
|
||||
|
||||
override connection = share(new NativeDBConnection(this.options));
|
||||
|
||||
constructor(private readonly options: SqliteNativeDBOptions) {
|
||||
super();
|
||||
}
|
||||
|
||||
get db() {
|
||||
return this.connection.apis;
|
||||
}
|
||||
|
||||
override async setBlobUploadedAt(
|
||||
peer: string,
|
||||
blobId: string,
|
||||
uploadedAt: Date | null
|
||||
): Promise<void> {
|
||||
await this.db.setBlobUploadedAt(peer, blobId, uploadedAt);
|
||||
}
|
||||
|
||||
override async getBlobUploadedAt(
|
||||
peer: string,
|
||||
blobId: string
|
||||
): Promise<Date | null> {
|
||||
return this.db.getBlobUploadedAt(peer, blobId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user