我有一个关于在nodejs中使用Oracle数据库的问题。如何从发布请求中按对象执行查询?
我的意思是可以从表单中获得一组不同的参数。
{'name':'foo'} or {'name':'foo', 'surname':'baz'} or {'name':'foo', 'surname':'baz', 'gender':'male'}
在oracledb模块中,我可以查询特定的绑定集
示例
....
connection.execute(
// The statement to execute
`SELECT department_id, department_name
FROM departments
WHERE department_id = :id`,
// The "bind value" 180 for the bind variable ":id"
[180],
....
也许有人会帮忙
var query = `
select department_id, department_name from departments
where
(department_id = :id_dep or :id_dep is null)
and
(department_name = :name_dep or :name_dep is null)
`;
var binds =
{id_dep: req.body.id_dep
,name_dep: req.body.name_dep}
;
等