[英]Unable to Execute procedure with multiple parameters
i am trying to work with Azure's DocumentDb to validate the user credentials for login but i am not able to get the proper result. 我正在尝试使用Azure的DocumentDb来验证用于登录的用户凭据,但我无法获得正确的结果。
Some Points: 1. this is a partitioned collection and i am passing the partition key. 一些要点:1.这是一个分区集合,我正在传递分区键。 2. i am passing an array as parameter.
2.我正在传递一个数组作为参数。
Here is my Code for calling the procedure: 这是我调用该过程的代码:
response = await client.ExecuteStoredProcedureAsync<string>(storedProcedurelink, new RequestOptions { PartitionKey = new PartitionKey(partitionKey) }, new dynamic[]{param});
and here is my code for the procedure: 这是我的程序代码:
function sample(param) {
var collection = getContext().getCollection();
var query = 'SELECT * FROM c where c.logindata.email="'+param[0]+'" and c.logindata.password="'+param[1]+'" and c.userid>0';
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
query,
function (err, feed, options) {
if (err) throw err;
if (!feed || !feed.length) getContext().getResponse().setBody('no docs found');
else getContext().getResponse().setBody(JSON.stringify(feed));
});
if (!isAccepted) throw new Error('The query was not accepted by the server.');
}
I am able to execute the query in the query explorer and get the proper result but when i call the procedure it always gives no docs found
. 我能够在查询浏览器中执行查询并获得正确的结果,但是当我调用该过程时,始终
no docs found
。 I don't know what i am doing wrong, can someone point me in right direction. 我不知道我在做什么错,有人可以指出我正确的方向。
I don't know what i am doing wrong.
我不知道我在做什么错。
As param[0]
and param[1]
can't get the expeted result in store procedure.We can test it from the Azure portal. 由于
param[0]
和param[1]
无法在存储过程中获得删除结果。我们可以从Azure门户对其进行测试。
can someone point me in right direction.
有人可以指出我正确的方向。
Please have a try to use 2 paramters in your case. 请尝试使用2个参数。
function sample(email,password) {
var collection = getContext().getCollection();
var query = 'SELECT * FROM c where c.logindata.email="'+email+'" and c.logindata.password="'+password+'" and c.userid>0';
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
query,
function (err, feed, options) {
if (err) throw err;
if (!feed || !feed.length) getContext().getResponse().setBody('no docs found');
else getContext().getResponse().setBody(JSON.stringify(feed));
});
if (!isAccepted) throw new Error('The query was not accepted by the server.');
}
And make sure that we can get the expected result from Azure Portal script exploer. 并确保我们可以从Azure Portal脚本浏览器中获得预期的结果。
In the C# code 在C#代码中
var user = "xxxxx";
var password = "xxxx";
var response = await client.ExecuteStoredProcedureAsync<string>(storedProcedurelink, new RequestOptions { PartitionKey = new PartitionKey(partitionKey) },user,password);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.