Node.js 如何从post API返回受影响的行数据以响应oracle DB和Node JS
我在oracle DB中使用node js,我使用post api插入数据我需要返回在响应中插入的数据,我尝试了result.affectedrows,但这是随行数而来的我需要数据有什么方法可以做到这一点吗。下面是一个获取由数据库中的触发器分配的ID的示例:Node.js 如何从post API返回受影响的行数据以响应oracle DB和Node JS,node.js,oracle,express,post,Node.js,Oracle,Express,Post,我在oracle DB中使用node js,我使用post api插入数据我需要返回在响应中插入的数据,我尝试了result.affectedrows,但这是随行数而来的我需要数据有什么方法可以做到这一点吗。下面是一个获取由数据库中的触发器分配的ID的示例: const createSql = `insert into employees ( first_name, last_name, email, phone_number, hire_date,
const createSql =
`insert into employees (
first_name,
last_name,
email,
phone_number,
hire_date,
job_id,
salary,
commission_pct,
manager_id,
department_id
) values (
:first_name,
:last_name,
:email,
:phone_number,
:hire_date,
:job_id,
:salary,
:commission_pct,
:manager_id,
:department_id
) returning employee_id
into :employee_id`;
async function create(emp) {
const employee = Object.assign({}, emp);
employee.employee_id = {
dir: oracledb.BIND_OUT,
type: oracledb.NUMBER
}
const result = await database.simpleExecute(createSql, employee);
employee.employee_id = result.outBinds.employee_id[0];
return employee;
}
module.exports.create = create;
这是我的一段话