MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / serialize

Function serialize

packages/core/fumadb/src/schema/serialize.ts:271–297  ·  view source on GitHub ↗
(
  value: unknown,
  col: AnyColumn,
  provider: SQLProvider
)

Source from the content-addressed store, hash-verified

269 * Encode to driver value
270 */
271export function serialize(
272 value: unknown,
273 col: AnyColumn,
274 provider: SQLProvider
275) {
276 if (value === null) return null;
277
278 if (col.type === "json") {
279 return JSON.stringify(value);
280 }
281
282 if (provider === "sqlite" && value instanceof Date) {
283 return value.getTime();
284 }
285
286 if (provider === "sqlite" && typeof value === "boolean") return value ? 1 : 0;
287
288 if (provider === "sqlite" && typeof value === "bigint") {
289 return writeBigInt64BE(value);
290 }
291
292 if (col.type === "binary" && value instanceof Uint8Array) {
293 return value;
294 }
295
296 return value;
297}

Callers 2

buildWhereFunction · 0.90
encodeValuesFunction · 0.90

Calls 1

writeBigInt64BEFunction · 0.85

Tested by

no test coverage detected