Creating Our Schema
In our schema, we'll have two collections, vote
and change
, with the following predicates:
vote/name
- unique, stringvote/yesVotes
- multi ref predicate, restricted to the_auth
collectionvote/noVotes
- multi ref predicate, restricted to the_auth
collectionchange/name
change/subject
- ref, indexedchange/predicate
- ref, restricted to the_predicate
collection, indexedchange/object
- string, indexedchange/doc
change/vote
- ref, restricted to thevote
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 areint
(numbers),string
(text), andref
(references). For aref
type, it is good practice to specify arestrictCollection
, so theref
can only refer to a subject in a specific collection.Some predicates may also need to be
unique
orindex
. These requirements are listed above.
Create the Schema
Create the two collections (vote and change) and nine predicates mentioned above.