Skip to content

Working with rows — ds_row

Ke edited this page Mar 7, 2019 · 10 revisions

Each returned row is wrapped within ds_row, a map like data type designed to allow you to work with row data in a fast convenient fashion. Each ds_row represents a row in the data source.

Accessing row data

(column::tag), find(column::tag), find(column::string) Return the value of the specified column:

	#row(::mycolumn)
	#row->find('mycolumn')

-> get(::column), ->get('column')

Returns the value of specified columns fails if not a current column.

-> get(integer)

Returns the column value at the specified index

-> asmap

Returns row data as an map.

-> asarray

Returns row data as an array

Accessing data source information

-> database

Database name the row belongs to.

-> table

Table name the row belongs to.

-> columns

Columns used by the current row.

-> keycolumn

Return the rows key column

-> keyvalue

Return the rows key value

-> keyvalues

Return the rows key columns and values (useful if multiple key columns)

Modifying internal data

The below methods can be used to modify the ds_row internal data. None of these methods affect the data source, although it is useful to be able work with a row as if it was a map or similar.

-> (column::tag) = value, (column::string) = value

Updates internal data — does not write to the data source.

-> find(column) = value, get(column) = value

Set the specified column

-> insert(pair)

Insert / update the specified column and value

-> modified

Returns a map of any modified values.

-> keys

Returns list of modified keys.

Modifying the data source

The ds_row type provides a number of methods that directly modify the row at the data source although generally it's more flexible and efficient to update rows with active_statements.

-> update(data::trait_foreach), update(p::pair,...)

Updates internal data and writes modified values to the data source.

-> update

Write any modified values to the data source.

-> set(column = value), set(column::tag) = value, set(column::string) = value

Updates internal data and writes specified value to the data source.

-> delete

Delete the row from the data source.