Function queryDatabase

  • Send an SQL-query to the configured database

    Type Parameters

    • T = any

    Parameters

    • query: string

      Query written in SQL

    • Rest ...values: any

      Array of values to replace question marks (?) in the query with. Replacing is done from left to right.

    Returns Promise<T[] | NonQueryResult | ApiFailReason>

    Returns a promise which can either fail (string with reason) or succeed (T[] with results)

    Throws

    When the API has not been properly configured using configure, an exception is thrown detailing the missing information.

    Example

    import { api } from "@hboictcloud/api";

    try {
    const data = await api.queryDatabase(
    "SELECT * FROM test WHERE name = ? and age <= ?",
    "Lennard", 30
    );

    console.log(data);
    }
    catch(reason) {
    console.log(reason);
    }

Generated using TypeDoc