📄 tanstack/db/latest/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer

File: CustomSQLiteSerializer.md | Updated: 11/15/2025

Source: https://tanstack.com/db/latest/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer



TanStack

DB v0v0

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

Latest

Search...

+ K

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

Framework

React logo

React

Version

Latest

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

On this page

CustomSQLiteSerializer

Copy Markdown

Type Alias: CustomSQLiteSerializer<TOutput, TSQLite>
====================================================

ts

type CustomSQLiteSerializer<TOutput, TSQLite> = Partial<{ [Key in keyof TOutput]: (value: TOutput[Key]) => Key extends keyof TSQLite ? TSQLite[Key] : never }>;


type CustomSQLiteSerializer<TOutput, TSQLite> = Partial<{ [Key in keyof TOutput]: (value: TOutput[Key]) => Key extends keyof TSQLite ? TSQLite[Key] : never }>;

Defined in: definitions.ts:52

A mapping type for custom serialization of object properties to SQLite-compatible values.

This type allows you to override, for keys in the input object (TOutput), a function that transforms the value to the corresponding SQLite type (TSQLite). Keys not specified will use the default SQLite serialization.

Generics
--------

  • TOutput: The input object type, representing the row data to be serialized.
  • TSQLite: The target SQLite-compatible type for each property, typically inferred from the table schema.

Usage
-----

Use this type to define a map of serialization functions for specific keys when you need custom handling (e.g., converting complex objects, formatting dates, or handling enums).

Example:

ts

const serializer: CustomSQLiteSerializer<MyRowType, MySQLiteType> = {
  createdAt: (date) => date.toISOString(),
  status: (status) => status ? 1 : 0,
  meta: (meta) => JSON.stringify(meta),
};


const serializer: CustomSQLiteSerializer<MyRowType, MySQLiteType> = {
  createdAt: (date) => date.toISOString(),
  status: (status) => status ? 1 : 0,
  meta: (meta) => JSON.stringify(meta),
};

Behavior
--------

  • Each key maps to a function that receives the value and returns the SQLite-compatible value.
  • Used by serializeForSQLite to override default serialization for specific columns.

Type Parameters
---------------
### TOutput

TOutput extends Record<string, unknown>

### TSQLite

TSQLite extends Record<string, unknown>

Edit on GitHub

Home

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics