UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

39 lines (38 loc) 1.31 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "jsonColumn", { enumerable: true, get: function() { return jsonColumn; } }); const _mysqlcore = require("drizzle-orm/mysql-core"); const jsonColumn = ()=>(0, _mysqlcore.customType)({ dataType () { // MariaDB will store in LONGTEXT with JSON constraint, but "json" remains correct on the DDL side return 'json'; }, toDriver (value) { return value == null ? null : JSON.stringify(value); }, fromDriver (value) { if (value == null) return null; if (typeof value === 'string') { try { return JSON.parse(value); } catch { // Corrupt or non-JSON value: returns null (or throws if you prefer) return null; } } // In the (rare) case where the driver already returns an object return value; } }); //# sourceMappingURL=columns.js.map