Good day! Tell me, please, is it possible to combine models of different collections for certain attributes into one collection?
I am looking for an analogous JOIN operation in SQL, where you can specify the tables and fields by which data is linked.
For example, there are 2 collections Backbone: Children and Parents . Each model in Parents has an ID , each Children model has PARENT_ID . It is necessary to link these collections by the attributes ID and PARENT_ID respectively, in order to obtain the collection of the model of which will contain the attributes of the models of both collections as a result. I will try to show this example:
//Эти коллекции существуют, берутся из БД var Child = Backbone.Model.extend({ id: some_id, prop1: prop1, prop2: prop2, parent_id: some_parent_id }); var Children = Backbone.Collection.extend({ model: Child }); var Parent = Backbone.Model.extend({ id: some_parent_id, prop3: prop3, prop4: prop4, }); var Parents = Backbone.Collection.extend({ model: Parent }); // Эту нужно получить программно из двух имеющихся var Result = Backbone.Model.extend({ id: some_id, parent_id: some_parent_id prop1: prop1, prop2: prop2, prop3: prop3, prop4: prop4, }); var Results = Backbone.Collection.extend({ model: Result });