Context-Dependent Functions
Some available functions are only available in certain contexts. For example, ?o, which gets the object of a triple is relevant for a _predicate/spec, but not for a _collection/spec. Context-dependent functions can be used alongside universal functions.
Linked is the full list of all available context-dependent functions.
Function code examples:
(< 1000 (?o))
(== (?auth_id) (?sid))
(+ (objT) 100)
To write a full function, which checks whether the previous object of the flake is greater than the (proposed) object of the flake, we could add the following function to our database:
[
{
"_id": "_fn",
"name": "decreaseObject?",
"code": "(> (?pO) (?o))",
"doc": "Checks whether the (proposed) object is less than the previous object."
}
]
Notice that because we do not use any params, we do not need to specify _fn/params
.