2.2.0 • Published 8 months ago

@forge/sql v2.2.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
8 months ago

Library for Forge environment.

Usage example:

import sql, { migrationRunner } from "@forge/sql";

const migrationResults = await migrationRunner
  .enqueue(
    'v001_create_example_table',
    `CREATE TABLE IF NOT EXISTS example (id INT PRIMARY KEY AUTOINCREMENT,name TEXT NOT NULL);`
  )
  .enqueue('v002_alter_example_table_add_age', `ALTER TABLE example ADD COLUMN age INT NOT NULL;`)
  .enqueue('v003_alter_example_table_add_index_age', `CREATE INDEX idx_example_age ON example (age);`)
  .run();

const listExamples = await sql.executeRaw('SELECT * FROM example');

const statement = sql.prepare('INSERT INTO test example(name, age) VALUES (?, ?)');

const insertUserResult = await statement.bindParams('John Doe', 42).execute();