저는 backbonejs에 초보자이며 친구리스트를 가져 와서 표시하는 프로젝트를하고 있습니다. 이 프로젝트에서 나는 parse.com을 데이터베이스로 사용하고 있습니다. 그러나 나는이 시점에서 재고가있다.backbonejs - 복수 모델 가져 오기
예를 들면 다음과 같습니다. 사용자 및 친구 모델에 다음 데이터가 있습니다.
var user = [
{
id: 'x1',
firstname: 'Ashik',
lastname: 'shrestha',
phone: '12321321',
mobile: '123213',
email: '[email protected]'
},
{
id: 'x2',
firstname: 'rokesh',
lastname: 'shrestha',
phone: '12321321',
mobile: '123213',
email: '[email protected]'
},
];
var friends = [
{
user_id: 'x1',
user_friend_id: 'x2'
},
{
user_id: 'x1',
user_friend_id: 'x4'
},
{
user_id: 'x1',
user_friend_id: 'x10'
},
{
user_id: 'x2',
user_friend_id: 'x25'
}
];
// 컬렉션 내가 원하는 것을 지금
var userCollection = Backbone.collection.extend({
model: user
});
var friendListCollection = Backbone.collection.extend({
model: friends
});
var friends = new friendListCollection();
?
친구 컬렉션 개체를 가져 오면 친구들의 세부 정보를 가진 친구 목록을 가져오고 싶습니다.
예 :
friends.fetch({
success: function(ob){
var ob =ob.toJSON();
// i want ob to be like
[
{
id: 'x2',
firstname: 'rokesh',
lastname: 'shrestha',
phone: '12321321',
mobile: '123213',
email: '[email protected]'
},
{
id: 'x4',
firstname: 'rokesh',
lastname: 'shrestha',
phone: '12321321',
mobile: '123213',
email: '[email protected]'
},
{
id: 'xx10',
firstname: 'rokesh',
lastname: 'shrestha',
phone: '12321321',
mobile: '123213',
email: '[email protected]'
},
]
}
});
내가 그들을 관련 새로운 컬렉션을 만들해야하거나이 작업을 수행하는 다른 방법이?
미리 감사드립니다.