feat: 支持postgresql

This commit is contained in:
xiaojunnuo
2024-07-17 01:30:00 +08:00
parent a917a7bca6
commit 3b19bfb429
23 changed files with 203 additions and 321 deletions
@@ -12,21 +12,11 @@ export class DbStorage implements IStorage {
this.storageService = storageService;
}
remove(
scope: string,
namespace: string,
version: string,
key: string
): Promise<void> {
remove(scope: string, namespace: string, version: string, key: string): Promise<void> {
throw new Error('Method not implemented.');
}
async get(
scope: string,
namespace: string,
version: string,
key: string
): Promise<string | null> {
async get(scope: string, namespace: string, version: string, key: string): Promise<string | null> {
const storageEntity = await this.storageService.get({
userId: this.userId,
scope: scope,
@@ -41,13 +31,7 @@ export class DbStorage implements IStorage {
return null;
}
async set(
scope: string,
namespace: string,
version: string,
key: string,
value: string
): Promise<void> {
async set(scope: string, namespace: string, version: string, key: string, value: string): Promise<void> {
await this.storageService.set({
userId: this.userId,
scope: scope,
@@ -16,13 +16,7 @@ export class StorageService extends BaseService<StorageEntity> {
return this.repository;
}
async get(where: {
scope: any;
namespace: any;
userId: number;
version: string;
key: string;
}) {
async get(where: { scope: any; namespace: any; userId: number; version: string; key: string }) {
if (where.userId == null) {
throw new Error('userId 不能为空');
}
@@ -31,15 +25,7 @@ export class StorageService extends BaseService<StorageEntity> {
});
}
async set(entity: {
id?: any;
scope: any;
namespace: any;
userId: number;
version: string;
value: string;
key: string;
}) {
async set(entity: { id?: any; scope: any; namespace: any; userId: number; version: string; value: string; key: string }) {
entity.id = null;
const query = { ...entity };
delete query.value;