Finkie Finkie - 1 year ago 53
Javascript Question

Extract a value that passed the truth test in a Parse Array


i saved an array of 2 users in parse , i want to extract in the array only the one who pass the truth test , only the one who is not equal to the current value of parse.User. this is what i'm doing

return != Parse.User.current().id

Doing this return me an undefined value

this is how i'm saving the array

function createRooms(){
var chatRooms = new ChatRooms();
var userOne = Parse.User.current()
var userTwo = AchatsDetailsData.value.seller
var chateur = [userOne, userTwo]
chatRooms.set("lastMessages", "undefined");
chatRooms.set("Users", chateur);{
}, function(error){


this is how i'm loading the data.

function loadrooms(){
var roomsQuery = new Parse.Query("ChatRooms")
roomsQuery.equalTo("Users", Parse.User.current())
roomsQuery.notEqualTo("lastMessages", "undefined")
function(oldItem, newItem){
return ==;
function(oldItem, newItem){
oldItem.time == newItem.get("updatedAt");
return new Rooms(, newItem.get("lastMessages"), newItem.get("Users"), newItem.get("updatedAt"), newItem)

function Rooms(id, lastmessage, user, time, parsObject){
var self = this; = id;
this.lastmessage = lastmessage;
this.user = user.find(function(e){
return != Parse.User.current().id
this.RigID = this.user.get("RigID");
this.time = time;
this.userName = this.user.get("nom") + " " + this.user.get("prenom")
this.parsObject = parsObject;
this.userpicture = this.user.get("photo"); = Observable(function(){
if(this.userpicture == null){
return ""
return this.userpicture

so i have 2 users in the array chateur when i click to createRooms function, i want to extract the user who is not equal to the current user for displaying my chat room

Answer Source

This code works perfectly , i just forget to include my Users array into the query


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download