n8n/packages/cli/test/integration/shared/db/variables.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
549 B
TypeScript
Raw Normal View History

import { randomString } from 'n8n-workflow';
import Container from 'typedi';
import { VariablesRepository } from '@/databases/repositories/variables.repository';
import { generateNanoId } from '@/databases/utils/generators';
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 } });
}