Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.44 KB

io.cozy.docrules.md

File metadata and controls

38 lines (29 loc) · 1.44 KB

Table of contents

Cozy DocRules doctype

io.cozy.docrules

This doctype represents docrules, i.e. rules used to retrieve documents in the Cozy.

  • _id: {string} - The fixed rule ID, that should respect this nomenclature: <editor-reverse-domain-name>.docrules/<rule-name>. For instance: io.cozy.docrules/payslips.
  • description: {string} - The rule description.
  • doctype: {string} - The doctype of the documents targeted by the rule.
  • rule: {object}
    • limit: {number} - The maximum number of documents to retrieve with this rule.
    • selector: {object} - The selector to target documents, following the Mango syntax

Note the rule attributes, i.e. limit and selector can be parametrised by using a {var-name} notation. In the example below, {date} is a rule parameter used to find payslips before this date, while {limit} restricts the number of documents retrieved.

See here for an example on how to pass parameters to a rule.

Example

{
  "_id": "io.cozy.docrules/payslips",
  "description": "Get payslips from the given date",
  "doctype": "io.cozy.files",
  "rule": {
    "limit": "{limit}",
    "selector": {
      "cozyMetadata.classification": "payslip",
      "cozyMetadata.createdAt": {
        "$lt": "{date}"
      }
    }
  }
}