16 lines
557 B
TypeScript
16 lines
557 B
TypeScript
import { DataSource } from 'typeorm';
|
|
import { PluginDataEntity } from '../../../entities';
|
|
import { SavePluginDataCommand } from '../../types';
|
|
|
|
export async function handleSavePluginData(command: SavePluginDataCommand, dataSource: DataSource): Promise<void> {
|
|
const { payload } = command;
|
|
|
|
await dataSource.getRepository(PluginDataEntity).save({
|
|
key: payload.key,
|
|
pluginId: payload.pluginId,
|
|
scope: payload.scope,
|
|
serverId: payload.serverId ?? '',
|
|
updatedAt: Date.now(),
|
|
valueJson: JSON.stringify(payload.value ?? null)
|
|
});
|
|
} |