I've been doing some research and don't see an example for my specific use case. So general architecture advice/resources would be appreciated.
I'm creating a address book.
Creating separate collections for the contacts and groups was easy, but now I'm kind of stuck.
It appears that Backbone-associations or Backbone-relational or even nesting.js would provide what I'm looking for. Looks like Backbone-associations is more performant than Backbone-relational. Does anybody have experience with any of the plugins? Is there an easier hand-code solution?
Could you have a backbone model representing a group and a collection. The group could contain an array of contactIds:
var Contact = Backbone.Model.extend({
defaults: {
name: "SomeName",
phone: "1234567890",
...
}
});
var Group = Backbone.Model.extend({
defaults: {
name: "someName",
contactIds: [1, 2, 3, 4]
}
});
var Contacts = Backbone.Collection.extend({
model: Contact
});
If you need to access the details of a contact stored in a given group, you could do something like:
contacts.get(id);
to return the individual contact's information for a CRUD operation. You could similarly maintain a collection of groups.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With