无法执行具有多个参数的过程 [英] Unable to Execute procedure with multiple parameters

查看:63
本文介绍了无法执行具有多个参数的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Azure的DocumentDb来验证用于登录的用户凭据,但是我无法获得正确的结果.

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.

一些要点: 1.这是一个分区集合,我正在传递分区键. 2.我正在传递一个数组作为参数.

Some Points: 1. this is a partitioned collection and i am passing the partition key. 2. i am passing an array as parameter.

这是我用来调用该过程的代码:

Here is my Code for calling the procedure:

response = await client.ExecuteStoredProcedureAsync<string>(storedProcedurelink, new RequestOptions { PartitionKey = new PartitionKey(partitionKey) }, new dynamic[]{param});

这是我的程序代码:

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.');
}

我能够在查询浏览器中执行查询并获得正确的结果,但是当我调用该过程时,它始终会给出no docs found.我不知道我在做什么错,有人可以向我指出正确的方向.

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. 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.

由于param[0]param[1]无法在存储过程中获得删除的结果.我们可以从Azure门户对其进行测试.

As param[0] and param[1] can't get the expeted result in store procedure.We can test it from the Azure portal.

有人能指出我正确的方向吗?

can someone point me in right direction.

请尝试在您的情况下使用2个参数.

Please have a try to use 2 paramters in your case.

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.');
}

并确保我们可以从Azure Portal脚本浏览器中获得预期的结果.

And make sure that we can get the expected result from Azure Portal script exploer.

在C#代码中

      var user = "xxxxx";
      var password = "xxxx";
      var response = await client.ExecuteStoredProcedureAsync<string>(storedProcedurelink, new RequestOptions { PartitionKey = new PartitionKey(partitionKey) },user,password);

这篇关于无法执行具有多个参数的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆