Export format reference

In Mochi, imports use the format .mochi. These are zip files that contain the following files: - data.edn or data.json - Any number of media files

The data.edn or data.json file contains information about the decks and cards to be imported. If using JSON, the file should be encoded with Transit semantics. For EDN, more information can be found here: Extensible Data Notation. The JSON format is recommended for large data sets due to the improved speed when importing. A sample data file might look like this:

{:version 2
 :decks [{:name "Sample deck"
          :cards [{:content "Sample card"}]}]
                  {:content "Another sample card"}]}]}

For a more complete example, you can export one of your own decks from your collection.

The top level data structure is a map with the following format:

Top level map

Required

  • :version - The number 2.

Optional


Deck

Required

  • :name - A string.

Optional

  • :id - A keyword. (0-9A-Za-z) Should be globally unique, at least 8 characters.
  • :cards - A vector of Cards.
  • :parent-id - An :id of another Deck. If provided, this deck will be nested under the parent deck in the sidebar.

Template

Required

  • :id - A keyword. (0-9A-Za-z) Should be globally unique, at least 8 characters.
  • :name - A string.

Optional

  • :id - A keyword. (0-9A-Za-z) Should be globally unique, at least 8 characters.
  • :content - A string. The actual mustache-enabled content of the template.
  • :fields - A map of Fields. At least one field needs to have a an ID of :name, which will act as the primary field for cards using this template and is used to represent them in parts of the UI.
  • :pos - A string. /[0-9A-Za-z]+/ The order that this template will be displayed in the template window. Templates are sorted lexicographically.

Field

Required

  • :id - A keyword. (0-9A-Za-z) Should be unique within a template, at least 8 characters.
  • :name - A string.

Optional

  • :type - A keyword. One of :text, :boolean, :speech, :image, :translate, :dictionary
  • :pos - A string. /[0-9A-Za-z]+/ The order that this field will be displayed. Fields are sorted lexicographically.
  • :options - A map of keywords to values. This field is only applicable for certain values of :type.
  • :lang - A string; language code; used for the :speech type. See Custom Components.
  • :from - A string; language code; used for the :translate and :dictionary field types.
  • :to - A string; language code; used for the :translate and :dictionary field types.
  • :boolean-default - A boolean. Used as a default value for the :boolean field type (checkbox).

Card

Required

  • :content - A string. The contents of the card.
  • :deck-id - An :id of the parent Deck.
    • NOTE: This is only necessary for cards in the top level :cards vector.

Optional

  • :id - A keyword. (0-9A-Za-z) Should be globally unique, at least 8 characters.
  • :name - A string. The name will show up when linking to this Card from markdown, as well as in other parts of the UI.
  • :pos - A string. /[0-9A-Za-z]+/ The order that this card will be displayed, relative to others in the deck page, as well as during learning. The cards will be sorted lexicographically.
  • :reviews - A vector of Reviews.
  • :fields - A map of field ids to values. Values are usually strings, but if the field is of type :boolean, then the value should be a boolean.

Review

Required

  • :date - The date the review happened.
  • :due - The date when this card is due next.
  • :interval - An integer. The time between the last review and the next due date
  • :remembered? - Whether the card was remembered or not