Maintain/merge multiple schemas for CRUD and search?

42 views
Skip to first unread message

Manos Batsis

unread,
Feb 17, 2014, 3:17:02 PM2/17/14
to backbon...@googlegroups.com
I was wondering how others maintain and perhaps merge schema definitions e.g. for overlapping models or different usecases like view, create, update, search etc?

Cheers,

Manos

Manos Batsis

unread,
Feb 22, 2014, 1:05:22 PM2/22/14
to backbon...@googlegroups.com
Here's what I did in case someone finds it useful. I have changed the schema() of my base model [1] to handle an action parameter. The function calls a sub model's schemaComplete() to get the schema for all the  actions and filters the appropriate parts. My submodels e.g. TextModel [2] provide a schemaComplete that adds a level in the schema notation to support multiple actions, including a default. Submodel's call their super model's schemaComplete, then use jquery's merge to provide a schema for the specified action.

[1] https://github.com/abissgr/calipso-hub/blob/master/calipso-hub-webapp/src/main/webapp/js/model/generic-model.js
[2] https://github.com/abissgr/calipso-hub/blob/master/calipso-hub-webapp/src/main/webapp/js/model/text.js
Reply all
Reply to author
Forward
0 new messages