我有简单的嵌套 JSON:
{
"user": {
"name": "John",
"related": {
"name": "Alice",
"related": {
"name": "Bob"
}
}
}
}
我有骨干关系模型“用户”:
(function(){
var User = Backbone.RelationalModel.extend({
defaults: {
name: "",
related: {}
},
// Linking this model to itself
relations: [{
type: Backbone.HasOne,
key: "related",
relatedModel: User // As I've expected it doesn't exist at this time
}]
})
})()
所以,问题是:如何将模型链接到自身?谢谢!