Skip to main content

Creating Our Schema

In our schema, we'll have two collections, vote and change, with the following predicates:

  • vote/name - unique, string
  • vote/yesVotes - multi ref predicate, restricted to the _auth collection
  • vote/noVotes - multi ref predicate, restricted to the _auth collection
  • change/name
  • change/subject - ref, indexed
  • change/predicate - ref, restricted to the _predicate collection, indexed
  • change/object - string, indexed
  • change/doc
  • change/vote - ref, restricted to the vote collection, unique

Subjects in the change collection contains all the details about the change that is proposed, as well as a reference to the relevant vote. You'll notice that the object of the proposed change can only be a string. This is to simplify this example, but in a real application, you might want to be able to vote on changes with other types of objects as well.

Do you remember how to create a schema?

Visit the Schema section.

  • Remember, you need to specify a type. The most basic and common types are int (numbers), string (text), and ref (references). For a ref type, it is good practice to specify a restrictCollection, so the ref can only refer to a subject in a specific collection.

  • Some predicates may also need to be unique or index. These requirements are listed above.

Create the Schema

Create the two collections (vote and change) and nine predicates mentioned above.