mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 00:54:06 -08:00
13 lines
548 B
TypeScript
13 lines
548 B
TypeScript
import { VariablesRepository } from '@/databases/repositories/variables.repository';
|
|
import { generateNanoId } from '@/databases/utils/generators';
|
|
import { randomString } from 'n8n-workflow';
|
|
import Container from 'typedi';
|
|
|
|
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 } });
|
|
}
|