从Appery.io数据库中检索数据

时间:2014-02-12 07:37:52

标签: javascript mysql sql rest

我正在使用Appery.io构建移动应用程序

打算创建一种功能,用户可以对其他简要查看的个人资料做出响应(+或 - )。用户应该只能响应一次。因此,当用户访问“个人档案页面”

时,无需再次显示该个人档案

--- PAGES --- --------------------------------- -------------------------------------------

响应页面 - 列出Loggedin用户已响应的所有响应

配置文件页面 - 视图配置文件Loggedin用户没有回复[一次一个配置文件]&能够回应(+或 - )

--- DATABASE ------------------------------------ -----------------------------------------

用户信息存储在用户[_id,用户名,密码,mobile_number]中 所有响应都存储在集合响应[_id,user_id,recipient_id,state]

--- 问题 ------------------------------------ -----------------------------------------

尝试跳过Loggedin用户已在响应页面中回复的配置文件

经过数小时的研究后,我无法找到解决问题的方法。

在Appery.io中,需要使用SERVER CODE来执行此操作。得到一些错误,我的服务器代码如下:

var DB_id = request.get("DB_id"); //Get the "DB_id" parameter from the request and store it 
var userName = request.get("userName"); //Store the user name
var token = request.get("token"); // Get token from localstorage varbiable UserSessiontoken
var usercollection = "Users"; 
var Reponsescollection = "Responses";
try {
  profiles = {};

 //gets a collection list and save it to the response
 //var profiles = Profile.getCollectionList("SELECT * FROM 'users' NOT IN (SELECT `user_id` FROM Responses WHERE `user_id`=  + 'userId' +)");

 //Make the query and save it to the profiles object
 profiles.query = profile.query(DB_id, usercollection, "parameters": {"where": {"user_id": {"$userId" : {"$nin": {"Reponsescollection"}}}}, token);

 profiles.profilesList = Profile.getCollectionList(profiles); //Call the getCollectionList and save its response to the profiles

  response.success(profiles); //Pass the result object to the response.
  response.success("This actually Works!!!");
} catch (e) {
  response.success("message: " + e.message + " ncode: " + e.code); //If something goes wrong error message will appear
}

--- ERROR MSGS ----------------------------------- ----------------------------------------

ON TEST TAB ----- 错误代码SCSE014:脚本执行失败

特别针对此问题的逐步解决方案非常感谢

0 个答案:

没有答案