mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
14 lines
533 B
TypeScript
14 lines
533 B
TypeScript
import { generateNanoId } from '@n8n/db';
|
|
import { Container } from '@n8n/di';
|
|
import { randomString } from 'n8n-workflow';
|
|
|
|
import { VariablesRepository } from '@/databases/repositories/variables.repository';
|
|
|
|
export async function createVariable(key = randomString(5), value = randomString(5)) {
|
|
return await Container.get(VariablesRepository).save({ id: generateNanoId(), key, value });
|
|
}
|
|
|
|
export async function getVariableOrFail(id: string) {
|
|
return await Container.get(VariablesRepository).findOneOrFail({ where: { id } });
|
|
}
|