javascript - Retriew object in relational field on parse.com -


i've created table in parse called user , there relational field friends pointing same table user.now i've fetched backbone collection of user , single user.how can list of object contained field friends?i've tried method backbone returns object this:object {__type: "relation", classname: "_user"}.

 var cur_user = parse.user.current().id;    var self = this;    models.utenti = new usercollection();    models.utenti.fetch({        success: function (object) {            var cur_user = parse.user.current().id;           // gives u user model            var user = models.utenti.get(cur_user);            // lets friends list not collection yet            // assuming it's object            var friends = user.get("friends"));           // create friends collection           var collections.friends = new friendcollection(friends);            var view = new friendsview({                collection: collections.friends            });            self.changepage(view);         },        error: function (amici, error) {            console.log("don t work");        } 

you need not use object in first place.. can directly use collection models collection of users.

so wrote way assuming there friends collection

 var friends = user.get("friends"));   // create friends collection    var collections.friends = new friendcollection(friends);    var view = new friendsview({        collection: collections.friends    }); 

but if friends list of users can create new usercollection friends object , pass view

var friends = user.get("friends")); // create friends collection var collections.friends = new usercollection(friends); var view = new friendsview({      collection: collections.friends  }); 

var cur_user = parse.user.current().id;    var self = this;    models.utenti = new usercollection();    models.utenti.fetch({        success: function (object) {            var cur_user = parse.user.current().id;           // gives u user model            var user = models.utenti.get(cur_user);            // lets friends list not collection yet            // assuming it's object            var friends = user.get("friends"));           // create friends collection            var collections.friends = new friendcollection(friends);            var view = new friendsview({                collection: collections.friends            });            self.changepage(view);         },        error: function (amici, error) {            console.log("don t work");        } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -