问题描述
我碰到与骨干头痛。我有指定的记录,其中有子记录,例如一个集合:外科医生已安排的程序,程序有设备,有些设备有需要的消耗品(气体,液体等)。如果我有一个骨干集合的外科医生的,那么每个外科医生都有一个型号 - 但他的程序和设备和耗材都将是纯醇'的Javascript数组和对象从JSON被解开了。
I've run into a headache with Backbone. I have a collection of specified records, which have subrecords, for example: surgeons have scheduled procedures, procedures have equipment, some equipment has consumable needs (gasses, liquids, etc). If I have a Backbone collection surgeons, then each surgeon has a model-- but his procedures and equipment and consumables will all be plain ol' Javascript arrays and objects after being unpacked from JSON.
我想我可以在SurgeonsCollection,使用parse()作出新ProcedureCollections,进而做出新的EquipmentCollections,但一段时间后,这正在变成一个毛球。为了让明智的服务器端有接触,它有一个外科医生和他的东西作为POST--所以传播上ConsumableModel设定自动地触发一个拯救下层次结构的单点也使得整个分层方法模糊。
I suppose I could, in the SurgeonsCollection, use the parse() to make new ProcedureCollections, and in turn make new EquipmentCollections, but after a while this is turning into a hairball. To make it sensible server-side there's a single point of contact that takes one surgeon and his stuff as a POST-- so propagating the 'set' on a ConsumableModel automagically to trigger a 'save' down the hierarchy also makes the whole hierarchical approach fuzzy.
有没有其他人遇到过这样的问题吗?你是怎么解决的?
Has anyone else encountered a problem like this? How did you solve it?
推荐答案
这可以在你的情况下有所帮助:https://github.com/PaulUithol/Backbone-relational
This can be helpful in you case: https://github.com/PaulUithol/Backbone-relational
您指定的关系为1:1,1:N,N:N,它会相应地解析JSON。它还创建一个全局存储跟踪的所有记录。
You specify the relations 1:1, 1:n, n:n and it will parse the JSON accordingly. It also create a global store to keep track of all records.
这篇关于对于骨干深层数据结构的任何建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!