Effect CommunityEC
Effect Community2y ago
6 replies
deeplaysit

Clarification Needed: Using `${sql.insert(toSave)}` with JSONB Column

before I go down this rabbit warren - just confirming that I can't use ${sql.insert(toSave)} with a jsonb column? I need to add the ::jsonb to that field

this doesn't feel right:

          const entries = toSave.map((r) => {
            return sql`(${r.calculationId}, ${r.revisionId}, ${r.snapshotId}, ${r.createdAt}, ${r.statementsJson}::jsonb)\n`
          })
          return sql`insert into calculations
            ("calculationId", "revisionId", "snapshotId", "createdAt", "statementsJson")
            values ${entries.map((r) => r)}
            returning *`
Was this page helpful?