Created
February 25, 2020 14:09
-
-
Save dunnock/edb5525391de9fb3f546cbfb768eca3b to your computer and use it in GitHub Desktop.
actix-node-benchmark: JavaScript get_tasks handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function get_tasks(params, offset, res) { | |
let conn = (params["full"] == "true") | |
? db.get_tasks_full() | |
: db.get_tasks(); | |
let { client, config } = await conn; | |
let values = [ | |
!!params["assignee_name"] ? `%${params["assignee_name"]}%` : null, | |
!!params["summary"] ? `%${params["summary"]}%` : null, | |
params["limit"] || 10 | |
]; | |
let query = Object.assign(config, { values }); | |
let resp = await client.query(query); | |
let result = resp.rows.map((row) => ({ | |
id: row[0], | |
summary: row[1], | |
assignee_id: row[2], | |
assignee_name: row[3], | |
description: (params["full"] == "true") ? row[4] : null | |
})); | |
res.send(result); | |
client.release(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment