refactor(core): fix for no-uncaught-json-parse warnings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import { ValueTransformer } from 'typeorm';
|
||||
import config from '../../../config';
|
||||
|
||||
@@ -16,8 +17,7 @@ export const lowerCaser = {
|
||||
*/
|
||||
export const objectRetriever: ValueTransformer = {
|
||||
to: (value: object): object => value,
|
||||
from: (value: string | object): object =>
|
||||
typeof value === 'string' ? (JSON.parse(value) as object) : value,
|
||||
from: (value: string | object): object => (typeof value === 'string' ? jsonParse(value) : value),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,8 +27,7 @@ export const objectRetriever: ValueTransformer = {
|
||||
const jsonColumn: ValueTransformer = {
|
||||
to: (value: object): string | object =>
|
||||
config.getEnv('database.type') === 'sqlite' ? JSON.stringify(value) : value,
|
||||
from: (value: string | object): object =>
|
||||
typeof value === 'string' ? (JSON.parse(value) as object) : value,
|
||||
from: (value: string | object): object => (typeof value === 'string' ? jsonParse(value) : value),
|
||||
};
|
||||
|
||||
export const sqlite = { jsonColumn };
|
||||
|
||||
Reference in New Issue
Block a user