mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
13 lines
494 B
TypeScript
13 lines
494 B
TypeScript
import { generateNanoId } from '@n8n/db';
|
|
import { VariablesRepository } from '@n8n/db';
|
|
import { Container } from '@n8n/di';
|
|
import { randomString } from 'n8n-workflow';
|
|
|
|
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 } });
|
|
}
|