In our schema, we'll have two collections,
change, with the following predicates:
vote/name- unique, string
vote/yesVotes- multi ref predicate, restricted to the
vote/noVotes- multi ref predicate, restricted to the
change/subject- ref, indexed
change/predicate- ref, restricted to the
change/object- string, indexed
change/vote- ref, restricted to the
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
ref(references). For a
reftype, it is good practice to specify a
restrictCollection, so the
refcan only refer to a subject in a specific collection.
Some predicates may also need to be
index. These requirements are listed above.
Create the Schema
Create the two collections (vote and change) and nine predicates mentioned above.