docs: update permission.rst for check constraint api (#4124)

* Update permission.rst for check constraint API

* Apply suggestions from code review

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* update UpdatePermission

Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
This commit is contained in:
Phil Freeman 2020-03-17 02:22:37 -07:00 committed by GitHub
parent 3dc5e04d4e
commit 979dedccc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -351,8 +351,13 @@ An example:
"filter" : {
"author_id" : "X-HASURA-USER-ID"
},
"check" : {
"content" : {
"_ne": ""
}
},
"set":{
"id":"X-HASURA-USER-ID"
"updated_at" : "NOW()"
}
}
}
@ -360,11 +365,13 @@ An example:
This reads as follows - for the ``user`` role:
* Allow updating only those rows where the ``check`` passes i.e. the value of the ``author_id`` column of a row matches the value of the session variable ``X-HASURA-USER-ID`` value.
* Allow updating only those rows where the ``filter`` passes i.e. the value of the ``author_id`` column of a row matches the value of the session variable ``X-HASURA-USER-ID``.
* If the above ``check`` passes for a given row, allow updating only the ``title``, ``content`` and ``category`` columns (*as specified in the* ``columns`` *key*).
* If the above ``filter`` passes for a given row, allow updating only the ``title``, ``content`` and ``category`` columns (*as specified in the* ``columns`` *key*).
* When this update happens, the value of the column ``id`` will be automatically ``set`` to the value of the resolved session variable ``X-HASURA-USER-ID``.
* After the update happens, verify that the ``check`` condition holds for the updated row i.e. that the value in the ``content`` column is not empty.
* When this update happens, the value of the column ``updated_at`` will be automatically ``set`` to the current timestamp.
.. note::
@ -421,7 +428,11 @@ UpdatePermission
* - filter
- true
- :ref:`BoolExp`
- Only the rows where this expression holds true are deletable
- Only the rows where this precondition holds true are updatable
* - check
- false
- :ref:`BoolExp`
- Postcondition which must be satisfied by rows which have been updated
* - set
- false
- :ref:`ColumnPresetExp`