Create a new TypeScript file for your userscript in your IDE (for example, userscript.ts).For IDE autocomplete and type-checking support, optionally add the Replicator TypeScript definitions. For details, refer to .
Use the as a starting point. The cookbook provides ready-to-use examples that you can copy and adapt.Copy and adapt a cookbook example that matches your use case. For example, adapt the template to to exclude the audit_logs table from the public schema during replication:
import * as api from "replicator@v2";const TARGET_SCHEMA_NAME = "defaultdb.public";const TABLE_TO_SKIP = "audit_logs";api.configureTargetSchema(TARGET_SCHEMA_NAME, { onRowUpsert: (row, meta) => { if (meta.table === TABLE_TO_SKIP) { return null; // Skip this table } return row; }, onRowDelete: (row, meta) => { if (meta.table === TABLE_TO_SKIP) { return null; } return row; }});
For details on the userscript API and handler functions, refer to the .