[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F3WMZYY4F3FMBHJK0BW965":3,"skill-same:01M6F3WMZYY4F3FMBHJK0BW965":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":64,"commitSha":65,"skillDirectory":66,"forksCount":67,"repositoryHtmlUrl":68,"repositoryHomepageUrl":69,"ownerHtmlUrl":70,"ownerBlogUrl":6,"ownerDescription":71,"updatedAt":72,"install":73,"resources":86},"01M6F3WMZYY4F3FMBHJK0BW965","electric-orm",null,"Use Electric with Drizzle ORM or Prisma for the write path. Covers getting pg_current_xact_id() from ORM transactions using Drizzle tx.execute(sql) and Prisma $queryRaw, running migrations that preserve REPLICA IDENTITY FULL, and schema management patterns compatible with Electric shapes. Load when using Drizzle or Prisma alongside Electric for writes.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",66,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Felectric-sql\u002Felectric\u002Felectric-orm\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"electric orm","orm","execute","with","drizzle","guides","id","prisma","migrations","schema","use","docs","management","write","drizzle orm","troubleshooting","transactions","Composition","website","sql","2026-11-10 10:12:30",false,"---\nname: electric-orm\ndescription: >\n  Use Electric with Drizzle ORM or Prisma for the write path. Covers getting\n  pg_current_xact_id() from ORM transactions using Drizzle tx.execute(sql)\n  and Prisma $queryRaw, running migrations that preserve REPLICA IDENTITY\n  FULL, and schema management patterns compatible with Electric shapes.\n  Load when using Drizzle or Prisma alongside Electric for writes.\ntype: composition\nlibrary: electric\nlibrary_version: '1.5.10'\nrequires:\n  - electric-shapes\n  - electric-schema-shapes\nsources:\n  - 'electric-sql\u002Felectric:AGENTS.md'\n  - 'electric-sql\u002Felectric:website\u002Fdocs\u002Fguides\u002Ftroubleshooting.md'\n---\n\nThis skill builds on electric-shapes and electric-schema-shapes. Read those first.\n\n# Electric — ORM Integration\n\n## Setup\n\n### Drizzle ORM\n\n```ts\nimport { drizzle } from 'drizzle-orm\u002Fnode-postgres'\nimport { sql } from 'drizzle-orm'\nimport { todos } from '.\u002Fschema'\n\nconst db = drizzle(pool)\n\n\u002F\u002F Write with txid for Electric reconciliation\nasync function createTodo(text: string, userId: string) {\n  return await db.transaction(async (tx) => {\n    const [row] = await tx\n      .insert(todos)\n      .values({\n        id: crypto.randomUUID(),\n        text,\n        userId,\n      })\n      .returning()\n\n    const [{ txid }] = await tx.execute\u003C{ txid: string }>(\n      sql`SELECT pg_current_xact_id()::xid::text AS txid`\n    )\n\n    return { id: row.id, txid: parseInt(txid) }\n  })\n}\n```\n\n### Prisma\n\n```ts\nimport { PrismaClient } from '@prisma\u002Fclient'\n\nconst prisma = new PrismaClient()\n\nasync function createTodo(text: string, userId: string) {\n  return await prisma.$transaction(async (tx) => {\n    const todo = await tx.todo.create({\n      data: { id: crypto.randomUUID(), text, userId },\n    })\n\n    const [{ txid }] = await tx.$queryRaw\u003C[{ txid: string }]>`\n      SELECT pg_current_xact_id()::xid::text AS txid\n    `\n\n    return { id: todo.id, txid: parseInt(txid) }\n  })\n}\n```\n\n## Core Patterns\n\n### Drizzle migration with REPLICA IDENTITY\n\n```ts\n\u002F\u002F In migration file\nimport { sql } from 'drizzle-orm'\n\nexport async function up(db) {\n  await db.execute(sql`\n    CREATE TABLE todos (\n      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n      text TEXT NOT NULL,\n      completed BOOLEAN DEFAULT false\n    )\n  `)\n  await db.execute(sql`ALTER TABLE todos REPLICA IDENTITY FULL`)\n}\n```\n\n### Prisma migration with REPLICA IDENTITY\n\n```sql\n-- prisma\u002Fmigrations\u002F001_init\u002Fmigration.sql\nCREATE TABLE \"todos\" (\n  \"id\" UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  \"text\" TEXT NOT NULL,\n  \"completed\" BOOLEAN DEFAULT false\n);\n\nALTER TABLE \"todos\" REPLICA IDENTITY FULL;\n```\n\n### Collection onInsert with ORM\n\n```ts\nimport { createCollection } from '@tanstack\u002Freact-db'\nimport { electricCollectionOptions } from '@tanstack\u002Felectric-db-collection'\n\nexport const todoCollection = createCollection(\n  electricCollectionOptions({\n    id: 'todos',\n    schema: todoSchema,\n    getKey: (row) => row.id,\n    shapeOptions: { url: '\u002Fapi\u002Ftodos' },\n    onInsert: async ({ transaction }) => {\n      const newTodo = transaction.mutations[0].modified\n      const { txid } = await createTodo(newTodo.text, newTodo.userId)\n      return { txid }\n    },\n  })\n)\n```\n\n## Common Mistakes\n\n### HIGH Not returning txid from ORM write operations\n\nWrong:\n\n```ts\n\u002F\u002F Drizzle — no txid returned\nconst [todo] = await db.insert(todos).values({ text: 'New' }).returning()\nreturn { id: todo.id }\n```\n\nCorrect:\n\n```ts\n\u002F\u002F Drizzle — txid in same transaction\nconst result = await db.transaction(async (tx) => {\n  const [row] = await tx.insert(todos).values({ text: 'New' }).returning()\n  const [{ txid }] = await tx.execute\u003C{ txid: string }>(\n    sql`SELECT pg_current_xact_id()::xid::text AS txid`\n  )\n  return { id: row.id, txid: parseInt(txid) }\n})\n```\n\nORMs do not return `pg_current_xact_id()` by default. Add a raw SQL query for txid within the same transaction. Without it, optimistic state may drop before the synced version arrives, causing UI flicker.\n\nSource: `AGENTS.md:116-119`\n\n### MEDIUM Running migrations that drop replica identity\n\nWrong:\n\n```ts\n\u002F\u002F ORM migration recreates table without REPLICA IDENTITY\nawait db.execute(sql`DROP TABLE todos`)\nawait db.execute(sql`CREATE TABLE todos (...)`)\n\u002F\u002F Missing: ALTER TABLE todos REPLICA IDENTITY FULL\n```\n\nCorrect:\n\n```ts\nawait db.execute(sql`DROP TABLE todos`)\nawait db.execute(sql`CREATE TABLE todos (...)`)\nawait db.execute(sql`ALTER TABLE todos REPLICA IDENTITY FULL`)\n```\n\nSome migration tools reset table properties. Always ensure `REPLICA IDENTITY FULL` is set after table recreation. Without it, Electric cannot stream updates and deletes correctly.\n\nSource: `website\u002Fdocs\u002Fguides\u002Ftroubleshooting.md:373`\n\nSee also: electric-new-feature\u002FSKILL.md — Full write-path journey including txid handshake.\nSee also: electric-schema-shapes\u002FSKILL.md — Schema design affects both shapes and ORM queries.\n\n## Version\n\nTargets @electric-sql\u002Fclient v1.5.10.\n\n","This skill builds on electric-shapes and electric-schema-shapes. Read those first.\n\n# Electric — ORM Integration\n\n## Setup\n\n### Drizzle ORM\n\n```ts\nimport { drizzle } from 'drizzle-orm\u002Fnode-postgres'\nimport { sql } from 'drizzle-orm'\nimport { todos } from '.\u002Fschema'\n\nconst db = drizzle(pool)\n\n\u002F\u002F Write with txid for Electric reconciliation\nasync function createTodo(text: string, userId: string) {\n  return await db.transaction(async (tx) => {\n    const [row] = await tx\n      .insert(todos)\n      .values({\n        id: crypto.randomUUID(),\n        text,\n        userId,\n      })\n      .returning()\n\n    const [{ txid }] = await tx.execute\u003C{ txid: string }>(\n      sql`SELECT pg_current_xact_id()::xid::text AS txid`\n    )\n\n    return { id: row.id, txid: parseInt(txid) }\n  })\n}\n```\n\n### Prisma\n\n```ts\nimport { PrismaClient } from '@prisma\u002Fclient'\n\nconst prisma = new PrismaClient()\n\nasync function createTodo(text: string, userId: string) {\n  return await prisma.$transaction(async (tx) => {\n    const todo = await tx.todo.create({\n      data: { id: crypto.randomUUID(), text, userId },\n    })\n\n    const [{ txid }] = await tx.$queryRaw\u003C[{ txid: string }]>`\n      SELECT pg_current_xact_id()::xid::text AS txid\n    `\n\n    return { id: todo.id, txid: parseInt(txid) }\n  })\n}\n```\n\n## Core Patterns\n\n### Drizzle migration with REPLICA IDENTITY\n\n```ts\n\u002F\u002F In migration file\nimport { sql } from 'drizzle-orm'\n\nexport async function up(db) {\n  await db.execute(sql`\n    CREATE TABLE todos (\n      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n      text TEXT NOT NULL,\n      completed BOOLEAN DEFAULT false\n    )\n  `)\n  await db.execute(sql`ALTER TABLE todos REPLICA IDENTITY FULL`)\n}\n```\n\n### Prisma migration with REPLICA IDENTITY\n\n```sql\n-- prisma\u002Fmigrations\u002F001_init\u002Fmigration.sql\nCREATE TABLE \"todos\" (\n  \"id\" UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  \"text\" TEXT NOT NULL,\n  \"completed\" BOOLEAN DEFAULT false\n);\n\nALTER TABLE \"todos\" REPLICA IDENTITY FULL;\n```\n\n### Collection onInsert with ORM\n\n```ts\nimport { createCollection } from '@tanstack\u002Freact-db'\nimport { electricCollectionOptions } from '@tanstack\u002Felectric-db-collection'\n\nexport const todoCollection = createCollection(\n  electricCollectionOptions({\n    id: 'todos',\n    schema: todoSchema,\n    getKey: (row) => row.id,\n    shapeOptions: { url: '\u002Fapi\u002Ftodos' },\n    onInsert: async ({ transaction }) => {\n      const newTodo = transaction.mutations[0].modified\n      const { txid } = await createTodo(newTodo.text, newTodo.userId)\n      return { txid }\n    },\n  })\n)\n```\n\n## Common Mistakes\n\n### HIGH Not returning txid from ORM write operations\n\nWrong:\n\n```ts\n\u002F\u002F Drizzle — no txid returned\nconst [todo] = await db.insert(todos).values({ text: 'New' }).returning()\nreturn { id: todo.id }\n```\n\nCorrect:\n\n```ts\n\u002F\u002F Drizzle — txid in same transaction\nconst result = await db.transaction(async (tx) => {\n  const [row] = await tx.insert(todos).values({ text: 'New' }).returning()\n  const [{ txid }] = await tx.execute\u003C{ txid: string }>(\n    sql`SELECT pg_current_xact_id()::xid::text AS txid`\n  )\n  return { id: row.id, txid: parseInt(txid) }\n})\n```\n\nORMs do not return `pg_current_xact_id()` by default. Add a raw SQL query for txid within the same transaction. Without it, optimistic state may drop before the synced version arrives, causing UI flicker.\n\nSource: `AGENTS.md:116-119`\n\n### MEDIUM Running migrations that drop replica identity\n\nWrong:\n\n```ts\n\u002F\u002F ORM migration recreates table without REPLICA IDENTITY\nawait db.execute(sql`DROP TABLE todos`)\nawait db.execute(sql`CREATE TABLE todos (...)`)\n\u002F\u002F Missing: ALTER TABLE todos REPLICA IDENTITY FULL\n```\n\nCorrect:\n\n```ts\nawait db.execute(sql`DROP TABLE todos`)\nawait db.execute(sql`CREATE TABLE todos (...)`)\nawait db.execute(sql`ALTER TABLE todos REPLICA IDENTITY FULL`)\n```\n\nSome migration tools reset table properties. Always ensure `REPLICA IDENTITY FULL` is set after table recreation. Without it, Electric cannot stream updates and deletes correctly.\n\nSource: `website\u002Fdocs\u002Fguides\u002Ftroubleshooting.md:373`\n\nSee also: electric-new-feature\u002FSKILL.md — Full write-path journey including txid handshake.\nSee also: electric-schema-shapes\u002FSKILL.md — Schema design affects both shapes and ORM queries.\n\n## Version\n\nTargets @electric-sql\u002Fclient v1.5.10.\n\n",{"name":5,"type":54,"library":55,"sources":56,"requires":59,"description":62,"library_version":63},"composition","electric",[57,58],"electric-sql\u002Felectric:AGENTS.md","electric-sql\u002Felectric:website\u002Fdocs\u002Fguides\u002Ftroubleshooting.md",[60,61],"electric-shapes","electric-schema-shapes","Use Electric with Drizzle ORM or Prisma for the write path. Covers getting pg_current_xact_id() from ORM transactions using Drizzle tx.execute(sql) and Prisma $queryRaw, running migrations that preserve REPLICA IDENTITY FULL, and schema management patterns compatible with Electric shapes. Load when using Drizzle or Prisma alongside Electric for writes.\n","1.5.10","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Felectric-sql\u002Felectric\u002Felectric-orm",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill electric-orm",{"tool":79,"command":80},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill electric-orm",{"tool":82,"command":83},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill electric-orm","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Felectric-sql\u002Felectric\u002Felectric-orm\u002FSKILL.md",true,[],[88,100,110,119,125,132],{"skillNo":89,"name":90,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":96,"publishedAt":49},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[93],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[97,98,99],"model","model hierarchy","model hierarchy skill",{"skillNo":101,"name":102,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":106,"publishedAt":49},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[105],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[107,108,109],"MCP","zoom","zoom mcp",{"skillNo":111,"name":112,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":49},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[116,117,118,108],"sdk","zoom apps sdk","apps",{"skillNo":120,"name":121,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":49},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[121],{"skillNo":126,"name":127,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":131,"publishedAt":49},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[130],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[127],{"skillNo":133,"name":134,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":49},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[134]]