Creating Predicates: Part 1
Now, we have four collections in our ledger: chat
, person
, comment
, and artist
, and we need to create predicates for those collections.
Creating Predicates
Collections and predicates are stored in the ledger the same way that any other type of information is stored.
When you are creating a new predicate, you are creating a new subject of type _predicate
, and that subject contains certain predicates. These are that particular predicate's predicates.
There are many predicates that you can specify for each predicate. The full list of built-in predicates can be found in the docs.
We will using the following predicate predicates:
_predicate/name
_predicate/doc
_predicate/type
_predicate/name
must be namespaced with the collection you intend it to be used within. For example, if you want to make a predicate for a person's name, it can't just be name
- it must be person/name
.
_predicate/type
is data type for this predicate. The full list of valid types can be found in the docs, but for this lesson we'll be only using: string
(text), int
(number), ref
(reference), and instant
(time represented by number of seconds).
If we want to create a predicate - person/fullName
that should be of type string
, meaning it is text. The transaction would look like this:
[{
"_id": "_predicate",
"name": "person/fullName",
"type": "string"
}]
Create `chat/message`
This predicate will contain the text of a chat message. Make sure to specify both the predicate name and type.