Creating Rules - Part 2
In the previous lesson, we added the following restriction:
wallet/name- only the owner of the wallet can edit
Now, we'll add the next two restrictions.
wallet/balance- anyone can edit
wallet/user- no one can edit.
In order to make sure that anyone can edit
wallet/balance, we can use the built-in smart functions,
["_fn/name", "true"], which always returns
Similarly, to make sure no one can edit
wallet/user, we can use the built-in smart function
See if you can create two rules, for each rule you need to specify the following:
- id : Names for the rules. We can call one
editAnyCryptoBalance, and the other
- doc : Description of this rule
- fns : A reference to any smart functions. We can reference the relevant smart functions with a unique two-tuple,
- ops : An array of operations that this rule would apply to. We'll be using either "query", "transact", or "all"
- collection : Name of the collection this rule applies to
- predicates : An array of the names of the predicates this rule applies to.
- errorMessage : An optional error message that would appear if someone is attempting a transaction that is not allowed according to the given rule.
(See all _rule predicates).
Create Two Rules
Using the instructions above, create two rules, one that allows anyone to edit `wallet/balance`, and the other that doesn't let anyone edit `wallet/user`.