Table of Contents
Documents from the database are loaded into the system through Backbone Models and Collections. These are extended in the CocoModel class. There's also the Supermodel class which coordinates the loading and populating of these models.
Supermodel
This class uses JSON-Schema to figure out, for a given model, what other models ought to be loaded. The logic for this is spread between Supermodel.coffee and CocoModel.coffee. This is used, for example, to load all documents required for a given Level model.
Saving
Models that are not versioned save just as they normally do with Backbone Models.
To save a new version of a versioned model, use the CocoModel's cloneNewMinorVersion and cloneNewMajorVersion. Typically, the process is to modify the model as normal with 'set', then clone with the changes and save the clone.
Backbone does not natively support nested documents, which CodeCombat relies heavily on. Currently, the only way to set a subdocument is to set the root level property. See how LevelBus.coffee does this with LevelSession.
Patching is supported by the server. LevelBus.coffee also shows how this is handled.
- Home
- Archmage Home
- Artisan Home
- Adventurer Home
- Scribe Home
- Diplomat Home
- Ambassador Home
- Archmage General
- Mission statement
- Coco Models
- Coding Guidelines
- Cookbook
- File system
- JSON Schema
- Technical overview
- Testing
- Third party software and services
- Artisan General
- Building A Level
- Coding Guidelines for Artisans
- Editing Thang Components
- Important Artisan Concepts
- Keyboard Shortcuts
- Artisan How-To Index
- Adventurer General
- Scribe General
- Diplomat General
- i18n
- i18n Glossary nb
- i18n Glossary ru
- i18n Glossary es-419
- Ambassador General
- Dev Setup
- Dev Setup: Linux
- Dev Setup: Windows
- Dev Setup: Mac
- Dev Setup: Vagrant
- Dev Setup: Issues
- Game Engine
- Component
- Multiplayer
- Surface
- System
- Thang
- Thang Component System
- Tome
- World
- Artisan Tabs
- Components And Systems
- Scripts
- Settings
- Thangs
- Other
- Aether
- Client models
- Developer organization
- Educational Standards
- Events, subscriptions, shortcuts
- Chat Room
- Chat Room Rules
- Permissions
- Project Ideas List
- Treema
- Versioning
- Views
CodeCombat | Home | Blog | Forum | Teachers | Legal | Contribute