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

Db.selectRow

Db.selectRow($sql, $whereMap = {}) -> map

Description

Return a single result of a SQL 'select' statement as a Map.

Note: A value will be converted to a Date object if it is a date/time column type, or if the column name ends in “date”.

// Get data for user #123
$query = sql'SELECT * FROM users WHERE id = {}'
$query.fill(123)

$user = Db.selectRow($query)

//= { id: 123, name: 'tania33', ... }

Where Map 

If $whereMap is given, a dynamic WHERE clause will be appended to the query.

$where = { postId: 1234, isDeleted: 0 }
Db.selectRow('SELECT * FROM posts', $where)

// Runs Query:
//   SELECT * FROM posts
//   WHERE postId = 1234
//   AND isDeleted = 0
//   LIMIT 1

See Also