INNER CODE UNIT · JavaScript

placeholders

currycan/HaTickets · desktop/src/sql/index.js:90

    const placeholders = keys.map(() => "?").join(", ");
    const values = keys.map(k => {
        const v = params[k];
        return typeof v === "object" ? JSON.stringify(v) : v;
    });

    return await db.execute(
        `INSERT INTO ${tableName} (${keys.join(", ")}) VALUES (${placeholders})`,
        values
    );
};

// !!!默认更新所有 - parameterized queries
export const update = async (tableName, params) => {
    if (!isAllowedTable(tableName)) {
        throw new Error(`Table "${tableName}" is not allowed`);
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…