0

New to backbone/marionette, but I believe that I understand how to use backbone when dealing with CRUD/REST; however, consider something like results from a search query. How should one model this? Of course the results likely relate to some model(s), but they are not meant to be tied to said model(s).

Part of me thinks that I should use a collection using a model that doesn't actually sync with a data store through the server, but instead just exists as a means of a modeling a search result object.

Another solution could be to have a collection with no models and just override parse.

I assume that the former is preferred, but again I have no experience with the framework. If there's an alternative/better solution than those listed above, please advise.

Steve P.
  • 14,489
  • 8
  • 42
  • 72

1 Answers1

0

I prefer having one object which is responsible for both request and response parsing. It can parse the response to appropriate models and nothing more. I mean - if some of those parsed models are required somewhere in your page, there is something that keeps reference to this wrapper object and takes models from response it requires via wrapper methods.

Another option is to have Radio (https://github.com/marionettejs/backbone.radio) in this wrapper - you will not have to keep wrapper object in different places but call for data via Radio.

djaszczurowski
  • 4,385
  • 1
  • 18
  • 28