Skip to content

Guides

Map a Drizzle table to contacts

Step-by-step: pick a Drizzle table, map its columns to contact fields, check the mapping in the CRM, and fix the common mistake that leaves a table empty.

This guide maps one Drizzle table to Clivly contacts, from the config to the first row in the CRM.

1. Find the table and its columns

Clivly reads table and column names from your schema. Use the names exactly as the database has them, such as full_name, not the TypeScript key fullName.

2. Add the entity

entities: {
  participants: { concept: "contact", source: "participants",
    fields: { name: "full_name", email: "email" } },
}

3. Wire the source

Pass the table to the SDK with a cursor column:

source: {
  contacts: fromDrizzle(db, participants, { cursorField: "updatedAt" }),
}

4. Check the connection

npx clivly status

Every line should pass, including the sync cursor.

Common mistake

If the contacts list stays empty, check the source on the entity. It is a table name. The key under source: in the SDK is a concept such as contacts. Mixing the two means the entity resolves to no source and nothing syncs.

Related: Entities & mapping.