diff --git a/docs/builtins/Database/fold-db.md b/docs/builtins/Database/fold-db.md index 328bd977..8a0fa844 100644 --- a/docs/builtins/Database/fold-db.md +++ b/docs/builtins/Database/fold-db.md @@ -1,6 +1,6 @@ ## fold-db -Use `fold-db` to select rows from a specified `table` using a predicate `query` with both a key and avalue, and then accumulate the results of the query using a `consumer` function. +Use `fold-db` to select rows from a specified `table` using a predicate `query` with both a key and a value, and then accumulate the results of the query using a `consumer` function. The output is sorted by the ordering of keys. ### Basic syntax @@ -40,6 +40,6 @@ The following example demonstrates how to use the `fold-db` function: In this example: - `(qry (lambda (k obj) true))` is a predicate that selects all rows. -- `(f (lambda (x) [(at 'firstName x), (at 'b x)]))` is a consumer function that selects the 'firstName' and 'b' fields from each row. +- `(f (lambda (x) [(at 'firstName x), (at 'b x)]))` is a consumer function that selects the "firstName" and "b" fields from each row. The `fold-db` function is then used to select rows from the `people` table using the predicate `qry` and accumulate the results using the consumer function `f`. The result is a list of accumulated results based on the selected rows and the specified consumer function. The `fold-db` function is useful for iterating over rows in a table and performing operations in Pact contracts. diff --git a/docs/builtins/Database/txlog.md b/docs/builtins/Database/txlog.md index b11fabc1..1d6129b1 100644 --- a/docs/builtins/Database/txlog.md +++ b/docs/builtins/Database/txlog.md @@ -1,13 +1,13 @@ ## txlog -Use `txlog` to return all updates made to a specified table in a particular transaction identified by its transaction identifier. +Use `txlog` to return all updates made to a specified `table` in a particular transaction identified by its transaction identifier. ### Basic syntax To retrieve all updates made to the specified `table` in a specific transaction identifier, use the following syntax: ```pact -(txlog TABLE TXID) +(txlog table txid) ``` ### Arguments @@ -17,7 +17,7 @@ Use the following arguments to specify the table and transaction identifier for | Argument | Type | Description | | --- | --- | --- | | `table` | `table: <{row}>` | Specifies the table from which to retrieve updates. | -| `txid` | integer | Specifies the transaction ID (TXID) for which updates are to be retrieved. | +| `txid` | integer | Specifies the transaction identifier (TXID) for which updates are to be retrieved. | ### Return value diff --git a/docs/builtins/Database/write.md b/docs/builtins/Database/write.md index 9f147f9c..e7e44cb1 100644 --- a/docs/builtins/Database/write.md +++ b/docs/builtins/Database/write.md @@ -1,13 +1,19 @@ ## write -Use `write` to write an entry in the specified table for a given key with the data provided in the object column. +Use `write` to write the specified `{column:value}` object in the specified `table` for a given `key` row. +The `write` function is similar to the `insert` and `update` functions, except that: + +- The `insert` function fails if data already exists for the specified `key` row. +- The `update` function fails if data does not exist for the specified `key` row. + +In both of these cases, the `write` function can succeed and update the table without failing. ### Basic syntax -To write an entry in a specified `table` for a specific `key` with the provided `object` column data, use the following syntax: +To write an entry in a specified `table` for a specific `key` with the provided `object`, use the following syntax: ```pact -(write TABLE KEY OBJECT) +(write table key object) ``` ### Arguments