Skip to content

Instantly share code, notes, and snippets.

@Phyks
Created October 5, 2016 02:22
Show Gist options
  • Save Phyks/3ff32f330537188f6c280fe4554e7936 to your computer and use it in GitHub Desktop.
Save Phyks/3ff32f330537188f6c280fe4554e7936 to your computer and use it in GitHub Desktop.
Models description for cozy

Models

The Cozy datastore stores documents, which can be seen as JSON objects. A doctype is simply a declaration of the fields in a given JSON object, to store similar objects in an homogeneous fashion.

Cozy ships a built-in list of doctypes for representation of most of the common documents (Bills, Contacts, Events, ...).

Whenever your app needs to use a given doctype, you should:

  • Check if this is a standard doctype defined in Cozy itself. If this is the case, you should add a model declaration in your app containing at least the fields listed in the main fields list for this doctype. Note that you can extend the Cozy-provided doctype with your own customs fields. This is typically what is done in Konnectors for the Bill doctype.
  • If no standards doctypes fit your needs, you should define your own doctype in your app. In this case, you do not have to put any field you want in your model, but you should crosscheck other cozy apps to try to homogeneize the names of your fields, so that your doctype data could be reused by other apps. This is typically the case for the Konnector doctype in Konnectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment