function insert
insert(
table: string,
values: Record<string, InValue | RawSql>
): { sql: string; args: InValue[]; }

Build an INSERT statement from a table name and column→value record.

insert("users", { name: "Alice", admin_level: encLevel })
// → { sql: "INSERT INTO users (name, admin_level) VALUES (?, ?)",
//     args: ["Alice", encLevel] }

insert("event_attendees", {
  event_id: 1,
  attendee_id: rawSql("last_insert_rowid()"),
  quantity: 2,
})
// → { sql: "INSERT INTO event_attendees (...) VALUES (?, last_insert_rowid(), ?)",
//     args: [1, 2] }

Parameters

table: string
values: Record<string, InValue | RawSql>

Return Type

{ sql: string; args: InValue[]; }

Usage

import { insert } from "doc.ts";