In the documentation you can insert data inside a table with the following syntax:
(insert table-name id {"parameter":parameterValue})
But here, in this example i have extra values in parameters before the brackets.
(insert loans-inventory (inventory-key loanId entityName) {"balance":loanAmount})
What (inventorty-key loanId and entintynName) syntax mean? (inventory-key) is a function.
inventory-key function
(defun inventory-key (loanId:string owner:string)
(format "{}:{}" [loanId owner]))
(inventory-key loanId entityName)
is a call to the inventory-key
function with loanId
and entityName
as arguments. It all returns a value that serves the purpose as a key to the row that is being inserted in the table.
The key used comes from the output of the inventory-key
function, which looking at the example (loans tutorial) it is a function that returns a string in the format of loanId:owner
, probably to make it unique.