backbone-relational

Bootstrapping data with Backbone using one query as opposed to multiple queries

霸气de小男生 提交于 2019-12-11 20:06:10
问题 Please correct me if I am wrong, but is one complex query less expensive than multiple small queries -> Question? Seems the question listed has opposing views. I was always taught that the most expensive operation is the opening and closing of the connection to the db. If that is the case, what is the most efficient way to bootstrap your data on application startup? For simplicities sake, lets say my application requires a collection of latest posts, latest categories, the logged in user, and

Backbone-Relational related models not being created

依然范特西╮ 提交于 2019-12-10 10:09:27
问题 I'm trying to create a nested, relational backbone project but I'm really struggling. The rough idea of what I'm trying to do is shown below but I was under the impression upon calling fetch() on Client, a number of bookings would automatically be created based on the bookings being returned as JSON. The format of my JSON can be seen beneath the outline of the MVC: /**************************************************** /* CLIENT MODEL - Logically the top of the tree /* has a BookingsCollection

How do I load sub-models with a foreign key relationship in Backbone.js?

≡放荡痞女 提交于 2019-12-10 09:42:59
问题 Sorry if this is a bit convoluted... I am still learning Backbone.js... What is the proper way to load & save Backbone models that have sub-models within themselves? (And should I even be having sub-models?) For example, (pardon the coffeescript), if I have something like: class Address extends Backbone.Model urlRoot: '/api/v1/address/' url: -> return @urlRoot+@id+'/?format=json' defaults: {'city': '', 'state': ''} class Person extends Backbone.Model urlRoot: '/api/v1/person/' url: -> return

How to represent UML Relations with Backbone-Relational?

主宰稳场 提交于 2019-12-09 13:36:43
问题 I have Class Diagram looking like this : ModelA 1------* ModelB 1------* ModelC 1------* ModelD Edit : The Data looks like that Data : { "Titel" : "ModelA", "ModelA" : [ { "Titel" : "ModelB1", "ModelB1" : [ { "Titel" : "ModelC1", "ModelC1":[ { "Titel" : "ModelD1" }, { "Titel" : "ModelD2" }, { "Titel" : "ModelD3" } }, { "Titel" : "ModelC2", "ModelC2":[ { "Titel" : "ModelD21" }, { "Titel" : "ModelD22" }, { "Titel" : "ModelD23" } }, ] }, { "Titel" : "ModelB2", "ModelB2" : [ { "Titel" : "ModelC1"

Saving Entries to Database Relationship (many-to-many) Table from a Backbone Project

怎甘沉沦 提交于 2019-12-08 21:21:30
I currently have two Backbone models: user and project. I would like to have a Backbone view containing a form that enables the creation of a new project, and the association of currently existing users (entries from the database users table) with this project. When a user completes this form and clicks the save button, the new project should be saved into the database (in the projects table) and the relationship between the saved project and the related users should be saved into a relationship table (projects_users table, containing the corresponding project id and the user id for each

Backbone-relational cannot instantiate two RelationalModel objects

China☆狼群 提交于 2019-12-08 19:19:04
问题 I am trying to implement BackboneRelational and keep getting "Cannot instantiate more than one Backbone.RelationalModel with the same id per type!" class App.Models.User extends Backbone.RelationalModel urlRoot : '/api/users' idAttribute: 'id' relations: [ type: Backbone.HasMany key: 'plots' relatedModel: 'App.Models.Plot' collectionType: 'App.Collections.Plots' includeInJSON: false reverseRelation: key: 'user_id', includeInJSON: 'id' ] class App.Models.Plot extends Backbone.RelationalModel

RequireJS + BackboneRelational + Self-Referential

十年热恋 提交于 2019-12-08 12:25:15
问题 I've been trying to follow the example here: Creating nested models with backboneJS + backbone-relational + requireJS And ended up having something different (since I need a Backbone.Collection, not a Backbone.RelationalModel): define(['exports', 'backbone', 'backbone.relational'], function (Exports, Backbone) { var ModuleModel = Backbone.RelationalModel.extend({ relations : [{ type : Backbone.HasMany, key : "children", relatedModel : 'ModuleModel', collectionType : 'ModuleCollection' }] });

Backbone.RelationalModel using requireJs

妖精的绣舞 提交于 2019-12-08 11:52:07
问题 I would like to use RelationalModel using requireJs. Here my code(*) When I run my module, I get the following warning message: Relation=d; no model, key or relatedModel (function (){a.apply(this,arguments)}, "tasks", undefined). My questions are: 1) what does the warning message means? 2) relatedModel and collectionType are well defined in my relations or should I export the model and the collection in define call? (*) define([ 'backbone', 'relationalModel' ], function (Backbone) { "use

Backbone relational events not firing?

拟墨画扇 提交于 2019-12-07 03:54:16
问题 class TheModel extends Backbone.RelationalModel relations:[ type: Backbone.HasMany key: 'subModels' relatedModel: SubModel collectionType: SubModels reverseRelation: key: 'TheModel' ] themodel = new the TheModel({subModels:[{#stuff},{#stuff},{#stuff}]}) I have createModels on so themodel.get('subModels') returns a collection of models. Now if I pass changed subModel data into mymodel themodel.set({subModels:[{changedstuff},{stuff},{stuff}]}) Shouldn't themodel throw a change event? It doesn't

Backbone outputing empty array for collection.models?

假如想象 提交于 2019-12-07 03:53:26
Having a problem where if I do apples = new Apples apples.fetch() console.log apples console.log apples.models console.log apples will out put the Apples Collection, with models: Array(10) listed inside the object. But, console.log apples.models outputs an empty array. Why does this happen? Thanks in advance. Shaked KO Are you trying to console.log the collection right after executing the fecth() method or waiting for the callback to be executed by using apples.on('reset', function(){ console.log(this.models);} ,this); ? I just tried this and it worked out for me. Backbone collections have a