1

user という名前の解析テーブルを作成しました。その中に、同じテーブル user を指すリレーショナル フィールド friends があります。バックボーンによって user のコレクションを取得し、単一の user を取得しました。オブジェクトがフィールド friends に含まれていますか?メソッド バックボーンを取得しようとしましたが、次のようなオブジェクトが返されます: オブジェクト {__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;
          // So this gives u a user Model
           var user = Models.utenti.get(cur_user);
           // Lets say the friends list is not a Collection yet
           // Assuming it's just an object
           var friends = user.get("friends"));
          // Create a 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");
       }
4

1 に答える 1

0

そもそもオブジェクトを使用する必要はありません。ユーザーの Models コレクションであるコレクションを直接使用できます。

なので、フレンズコレクションがあると仮定して、このように書きました

 var friends = user.get("friends"));
  // Create a Friends Collection
   var Collections.friends = New FriendCollection(friends);
   var view = new FriendsView({
       collection: Collections.friends
   });

ただし、友達がユーザーのリストでもある場合はnew UserCollection、友達オブジェクトから を作成し、それをビューに渡すことができます

var friends = user.get("friends"));
// Create a 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;
          // So this gives u a user Model
           var user = Models.utenti.get(cur_user);
           // Lets say the friends list is not a Collection yet
           // Assuming it's just an object
           var friends = user.get("friends"));
          // Create a 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");
       }
于 2013-07-31T21:00:52.607 に答える