Version: v0.8.1 - Beta.  We welcome contributors & feedback.

Db.insertRow

Db.insertRow($table, $rowMap) -> null

Description

Insert a row into a table, where each Map key corresponds to a table column.

$row = {
    name: 'Ann'
    role: 'Analyst'
    createDate: Date.now()
}

Db.insertRow('users', $row)

// Runs query:
// INSERT INTO users (name, role, createDate)
//    VALUES ("Ann", "Analyst", "2021-03-23 16:38:11")

Object Values

If an inserted value is an object, it will try to convert it to a string based on its type.

Type Conversion
Date $date.format('sql')
Password $password.hash()
Other $object.onToSqlString() (default: toString())

See Also