Click here to Skip to main content
14,732,982 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building an mobile application using

Intend to create a functionality where users can respond (+ or -) to others profile which is briefly viewed. A user should only be able to respond Once. Hence it is unnecessary to show that profile again when the user visit Profiles Page

--- <b>PAGES </b>--- ---------------------------------------------------------------------------------

Reponses Page - List all reponses the Loggedin User has RESPONDED

Profiles Page - Views profiles Loggedin User has NOT RESPONDED [One Profile at a time] & Ability to respond (+ or -)

--- <b>DATABASE </b>-------------------------------------------------------------------------------

User Information are stored in users[_id, username, password, mobile_number]
All responses are stored in a collection responses[_id, user_id, recipient_id, state]

PROBLEM -----------

Trying to skip the profiles that the Loggedin User has already reponded to in Responses Page

In it is required to use SERVER CODE to do this. I am getting a few errors, my server code is as follows:

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

//ON TEST TAB -----
Error code SCSE014: Script execution failed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900