Database Operations
Learn about Zephyr's database operations
Zephyr currently supports the following types of database interactions:
Write.
Read.
Update.
On the guest level, there is no auth to handle so this is pretty straightforward as you don't have to grant any special permissions.
Write
In the Zephyr VM, or better in the Mercury abstraction of the VM implementation, a write operation translates to a SQL insert statement and it is performed by providing a constructed DatabaseDerive
object to the EnvClient::put()
function:
Read
Reading means returning an iterator (a vec currently) over DatabaseDerive
elements, as many as the rows present in the requested table. It is done by simply calling EnvClient::read()
while inferring the requested table type (which will automatically translate to reading from the corresponding table):
Update
Updating lets you update a selection of rows with a given row given the provided conditions:
In this snippet, all rows where the hello
column equals to the message
scval will be updated with the row defined by table
.
Last updated