Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js “环回”;“参数”;用于运行本机SQL查询_Node.js_Postgresql_Loopbackjs - Fatal编程技术网

Node.js “环回”;“参数”;用于运行本机SQL查询

Node.js “环回”;“参数”;用于运行本机SQL查询,node.js,postgresql,loopbackjs,Node.js,Postgresql,Loopbackjs,有人知道回送文档的“参数”是什么吗 它说: 执行本机SQL 要直接针对数据连接模型执行SQL,请使用以下命令: dataSource.connector.execute(sql, params, cb); 或 其中: sql—sql字符串。 params—SQL语句的参数。 cb-回调函数,它是SQL字符串参数值的数组。例如,如果您有postgresql数据库和参数化查询,如下所示: select * from table where id = $1 or name = $2 var q

有人知道回送文档的“参数”是什么吗

它说:

执行本机SQL

要直接针对数据连接模型执行SQL,请使用以下命令:

dataSource.connector.execute(sql, params, cb); 

其中: sql—sql字符串。 params—SQL语句的参数。
cb-回调函数,它是SQL字符串参数值的数组。例如,如果您有postgresql数据库和参数化查询,如下所示:

select * from table where id = $1 or name = $2
var query = "select * from table where id = $1 or name = $2";
var params = [82, "My name"];
ds.connector.execute(query, params, function(err, data){
  if(err){
    console.log( err);
  }else{
    console.log(data);
  }
});
然后,您必须为函数提供参数值,因此您将执行以下操作:

select * from table where id = $1 or name = $2
var query = "select * from table where id = $1 or name = $2";
var params = [82, "My name"];
ds.connector.execute(query, params, function(err, data){
  if(err){
    console.log( err);
  }else{
    console.log(data);
  }
});

阿兹是我最喜欢的说唱歌手之一,顺便问一下:)SQL小姐怎么样?我两个都试过了?而且$1也不起作用。MS SQL使用@param1而不是$1