mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-04 02:37:46 +02:00
21 lines
682 B
TypeScript
21 lines
682 B
TypeScript
import { ValueTransformer } from 'typeorm';
|
|
|
|
export const idStringifier = {
|
|
from: (value: number): string | number => (typeof value === 'number' ? value.toString() : value),
|
|
to: (value: string): number | string => (typeof value === 'string' ? Number(value) : value),
|
|
};
|
|
|
|
export const lowerCaser = {
|
|
from: (value: string): string => value,
|
|
to: (value: string): string => (typeof value === 'string' ? value.toLowerCase() : value),
|
|
};
|
|
|
|
/**
|
|
* Unmarshal JSON as JS object.
|
|
*/
|
|
export const objectRetriever: ValueTransformer = {
|
|
to: (value: object): object => value,
|
|
from: (value: string | object): object =>
|
|
typeof value === 'string' ? (JSON.parse(value) as object) : value,
|
|
};
|