DataRow shim, provides methods to manage objects as Ado.Net DataRows
Classes
Methods
(inner) acceptChanges() → {DataRow}
Makes changes permanents, discarding old values. state becomes unchanged, detached remains detached
Returns:
- Type
- DataRow
(inner) acceptChanges()
Accept any changes setting all dataRows in the state of 'unchanged'.
Deleted rows become detached and are removed from the table
(inner) acceptChanges()
Calls acceptChanges to all contained DataTables
(inner) add(obj)
Adds an object to the table setting the datarow in the state of "added"
Parameters:
Name | Type | Description |
---|---|---|
obj |
plain object |
Returns:
DataRow created
(inner) addTable(table) → {DataTable}
Adds a datatable to DataSet
Parameters:
Name | Type | Description |
---|---|---|
table |
DataTable |
Returns:
- Type
- DataTable
(inner) assignField(r, field, value)
Assign a value to a field and update all dependencies
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
field |
string | |
value |
object |
(inner) autoIncrement(fieldName, autoIncrementInfoopt) → {*|AutoIncrementColumn}
Get/Set autoincrement properties of fields
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fieldName |
string | ||
autoIncrementInfo |
object |
<optional> |
//see AutoIncrementColumn properties for details |
Returns:
- Type
- * | AutoIncrementColumn
(inner) avoidCollisions(r, field, value)
check if changing a key field of a row it would collide with come autoincrement field. If it would,
recalculates colliding rows/filter in accordance
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
field |
string | |
value |
object |
(inner) cachedMaxSubstring(field, start, len, filter) → {number}
Evaluates the max of an expression eventually using a cached value
Parameters:
Name | Type | Description |
---|---|---|
field |
string | |
start |
number | |
len |
number | |
filter |
sqlFun |
Returns:
- Type
- number
(inner) calcTemporaryId(r, fieldopt)
Augment r[field] in order to avoid collision with another row that needs to take that value
if field is not specified, this is applied to all autoincrement field of the table
Precondition: r[[field] should be an autoincrement field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
r |
ObjectRow | ||
field |
string |
<optional> |
(inner) cascadeDelete(row) → {*}
Deletes a row with all subentity child
Parameters:
Name | Type | Description |
---|---|---|
row |
ObjectRow |
Returns:
- Type
- *
(inner) childRelations()
Get all relation where THIS table is the parent and another table is the child
Returns:
DataRelation[]
(inner) clear()
Clears the table detaching all rows.
(inner) clearDefaults()
Clears any stored default value for the table
(inner) clearMaxCache()
Clear evaluated max cache
(inner) clone() → {DataTable}
clones table structure without copying any DataRow
Returns:
- Type
- DataTable
(inner) clone() → {DataSet}
Clones a DataSet replicating its structure but without copying any ObjectRow
Returns:
- Type
- DataSet
(inner) columnList()
get the list of columns or * if there is no column set
Returns:
string
(inner) copy() → {DataSet}
Creates a copy of the DataSet, including both structure and data.
Returns:
- Type
- DataSet
(inner) customFunction(r, columnName, conn) → {object}
Optional custom function to be called to evaluate the maximum value
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
columnName |
string | |
conn |
jsDataAccess |
Returns:
- Type
- object
(inner) defaults(defopt) → {object|*}
Get/set the object defaults in a JQuery fashioned style. When def is present, its fields and values are
merged into existent defaults.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
def |
<optional> |
Returns:
- Type
- object | *
(inner) del() → {DataRow}
Deletes the row. If it is in added state it becomes detached. Otherwise any changes are lost, and
only rejectChanges can bring the row into life again
Returns:
- Type
- DataRow
(inner) denyClear(argopt) → {*|string}
Get/Set DenyClear. === y avoid to clear table on backend reads
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
arg |
string |
<optional> |
Returns:
- Type
- * | string
(inner) deSerialize(d, deSerializeStructure)
Restores data from an object obtained with serialize().
Parameters:
Name | Type | Description |
---|---|---|
d |
object | |
deSerializeStructure |
boolean |
(inner) detach() → {undefined}
Detaches row, loosing all changes made. object is also removed from the underlying DataTable.
Proxy is disposed.
Returns:
- Type
- undefined
(inner) detach(obj)
Detaches a row from the table
Parameters:
Name | Type | Description |
---|---|---|
obj |
(inner) existingRow(obj) → {DataRow|undefined}
check if a row is present in the table. If there is a key, it is used for finding the row,
otherwise a ==== comparison is made
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
Returns:
- Type
- DataRow | undefined
(inner) getAutoIncrementColumns()
Gets all autoincrement column names of this table
Returns:
string[]
(inner) getChanges() → {Array}
gets an array of all modified/added/deleted rows
Returns:
- Type
- Array
(inner) getChild(parentRow) → {Array.<ObjectRow>}
Get any child of a given ObjectRow following this DataRelation
Parameters:
Name | Type | Description |
---|---|---|
parentRow |
ObjectRow |
Returns:
- Type
- Array.<ObjectRow>
(inner) getChildFilter(parentRow, aliasopt)
Gets a filter that will be applied to the child table and will find any child row of a given ObjectRow
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parentRow |
ObjectRow | ||
alias |
string |
<optional> |
when present is used to attach an alias for the parent table in the composed filter |
(inner) getChildInTable(childTableName) → {Array.<ObjectRow>}
Gets child rows of this row in a given table
Parameters:
Name | Type | Description |
---|---|---|
childTableName |
string |
Returns:
- Type
- Array.<ObjectRow>
(inner) getChildRows(relName) → {Array.<ObjectRow>}
Gets the child(s) of this row in the dataSet it is contained, following the relation with the
specified name
Parameters:
Name | Type | Description |
---|---|---|
relName |
string |
Returns:
- Type
- Array.<ObjectRow>
(inner) getExpression(r) → {sqlFun}
gets the expression to be used for retrieving the max
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow |
Returns:
- Type
- sqlFun
(inner) getMaxExpr(field, expr, filter) → {number}
gets the max in cache for a field and updates the cache
Parameters:
Name | Type | Description |
---|---|---|
field |
string | |
expr |
sqlFun | string | |
filter |
sqlFun |
Returns:
- Type
- number
(inner) getOptimisticLock(r) → {sqlFun}
Get the optimistic lock for updating or deleting a row
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow |
Returns:
- Type
- sqlFun
(inner) getParentRows(relName) → {Array.<ObjectRow>}
Gets the parent(s) of this row in the dataSet it is contained, following the relation with the
specified name
Parameters:
Name | Type | Description |
---|---|---|
relName |
string |
Returns:
- Type
- Array.<ObjectRow>
(inner) getParents(childRow) → {Array.<ObjectRow>}
Get any parent of a given ObjectRow following this DataRelation
Parameters:
Name | Type | Description |
---|---|---|
childRow |
ObjectRow |
Returns:
- Type
- Array.<ObjectRow>
(inner) getParentsFilter(childRow, aliasopt)
Gets a filter that will be applied to the parent table and will find any parent row of a given ObjectRow
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
childRow |
object | ||
alias |
string |
<optional> |
when present is used to attach an alias for the parent table in the composed filter |
(inner) getParentsInTable(parentTableName) → {Array.<ObjectRow>}
Gets parents row of this row in a given table
Parameters:
Name | Type | Description |
---|---|---|
parentTableName |
string |
Returns:
- Type
- Array.<ObjectRow>
(inner) getPrefix(r)
Gets the prefix evaluated for a given row
Parameters:
Name | Type | Description |
---|---|---|
r |
Returns:
string
(inner) getRow() → {DataRow}
Gets the DataRow linked to an ObjectRow
Returns:
- Type
- DataRow
(inner) getSelector(r) → {sqlFun}
evaluates the function to filter selector on a specified row and column
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow |
Returns:
- Type
- sqlFun
(inner) getValue(fieldName, dataRowVeropt) → {object}
get the value of a field of the object. If dataRowVer is omitted, it's equivalent to o.fieldName
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fieldName |
string | |||
dataRowVer |
DataRowVersion |
<optional> |
'current' | possible values are 'original', 'current' |
Returns:
- Type
- object
(inner) hasChanges() → {boolean}
Check if any DataRow in the table has changes
Returns:
- Type
- boolean
(inner) hasChanges() → {boolean}
Check if any contained DataTable has any changes
Returns:
- Type
- boolean
(inner) importData(d)
Import data from a given dataset
Parameters:
Name | Type | Description |
---|---|---|
d |
DataSet |
(inner) importRow(row) → {DataRow}
import a row preserving it's state, the row should already have a DataRow attached
Parameters:
Name | Type | Description |
---|---|---|
row |
object | input |
Returns:
created
- Type
- DataRow
(inner) isEntityRelation() → {boolean}
Establish if a relation links the key of a table into a subset of another table key
Returns:
- Type
- boolean
(inner) isOptimized() → {boolean}
Check if this table is optimized
Returns:
- Type
- boolean
(inner) key(kopt) → {*|Array.<string>}
Get/Set the primary key in a Jquery fashioned style. If k is given, the key is set, otherwise the existing
key is returned
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
k |
Array.<string> |
<optional> |
Returns:
- Type
- * | Array.<string>
(inner) keyFilter(row) → {*|sqlFun}
Get the filter that compares key fields of a given row
Parameters:
Name | Type | Description |
---|---|---|
row |
object |
Returns:
- Type
- * | sqlFun
(inner) keySample() → {object}
Get an object with all key fields of this row
Returns:
- Type
- object
(inner) load(obj, safeopt) → {DataRow}
Adds an object to the table setting the datarow in the state of "unchanged"
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj |
object | plain object to load in the table | ||
safe |
boolean |
<optional> |
true | if false doesn't verify existence of row |
Returns:
created DataRow
- Type
- DataRow
(inner) loadArray(arr, safe)
Adds an object to the table setting the datarow in the state of 'unchanged'
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<object> | array of plain objects |
safe |
boolean | if false doesn't verify existence of row |
Returns:
*
(inner) makeChild(childRow, parentTable, parentRowopt)
Make childRow child of parentRow if a relation between the two is found
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
childRow |
object | ||
parentTable |
string | ||
parentRow |
ObjectRow |
<optional> |
(inner) makeChild(parentRow, childRow) → {*}
Modifies childRow in order to make it child of parentRow. Sets to null corresponding fields if
parentRow is null or undefined
Parameters:
Name | Type | Description |
---|---|---|
parentRow |
ObjectRow | |
childRow |
ObjectRow |
Returns:
- Type
- *
(inner) makeEqualTo(o) → {DataRow}
changes current row to make it's current values equal to another one. Deleted rows becomes modified
compared to patchTo, this also removes values that are not present in other row
Parameters:
Name | Type | Description |
---|---|---|
o |
object |
Returns:
- Type
- DataRow
(inner) mergeArray(arr, overwrite) → {*}
adds an array of objects to collection, as unchanged, if they still are not present. Existence is verified
basing on key
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<Object> | |
overwrite |
boolean |
Returns:
- Type
- *
(inner) mergeAsPatch(t)
merges changes from dataTable t assuming they are unchanged and they are all present in this dataTable.
Rows are updated, but only fields actually present in d are modified. Other field are left unchanged.
It is assumed that "this" dataTable is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
t |
DataTable |
(inner) mergeAsPatch(d)
merges changes from DataSet d assuming they are unchanged and they are all present in this dataset.
Rows are updated, but only fields actually present in d are modified. Other field are left unchanged.
It is assumed that "this" dataset is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
d |
DataSet |
(inner) mergeAsPost(t)
merges changes from dataTable t assuming they are unchanged and they are not present in this dataTable.
Rows are all added 'as is' to this, in the state of ADDED
It is assumed that "this" dataTable is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
t |
DataTable |
(inner) mergeAsPost(d)
merges changes from DataSet d assuming they are unchanged and they are not present in this dataset.
Rows are all added 'as is' to this, in the state of ADDED
It is assumed that "this" dataset is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
d |
DataSet |
(inner) mergeAsPut(t)
merges changes from dataTable t assuming they are unchanged and they can be present in this or not.
If a row is not present, it is added. If it is present, it is updated.
It is assumed that "this" dataTable is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
t |
DataTable |
(inner) mergeAsPut(d)
merges changes from DataSet d assuming they are unchanged and they can be present in this or not.
If a row is not present, it is added. If it is present, it is updated.
It is assumed that "this" dataset is unchanged at the beginning
Parameters:
Name | Type | Description |
---|---|---|
d |
DataSet |
(inner) minimumTempValue(field, valueopt)
get/set the minimum temp value for a field, assuming 0 if undefined
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
field |
string | ||
value |
number |
<optional> |
(inner) newRelation(relationName, parentTableName, parentColsName, childTableName, childColsName) → {DataRelation}
Creates a new DataRelation and attaches it to the DataSet
Parameters:
Name | Type | Description |
---|---|---|
relationName |
string | |
parentTableName |
string | |
parentColsName |
Array.<string> | array of string |
childTableName |
string | |
childColsName |
Array.<string> | array of string |
Returns:
- Type
- DataRelation
(inner) newRow(objopt, parentRowopt) → {object}
creates a DataRow and returns the created object. The created object has the default values merged to the
values in the optional parameter obj.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object |
<optional> |
contains the initial value of the created objects. |
parentRow |
ObjectRow |
<optional> |
Returns:
- Type
- object
(inner) newTable(tableName) → {DataTable}
Creates a new DataTable attaching it to the DataSet
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string |
Returns:
- Type
- DataTable
(inner) originalRow() → {object}
Gets the original row, before changes was made, undefined if current state is added
Returns:
- Type
- object
(inner) parentRelations()
Get all relation where THIS table is the child and another table is the parent
Returns:
DataRelation[]
(inner) patchTo(o) → {DataRow}
changes current row to make it's current values equal to another one. Deleted rows becomes modified
Parameters:
Name | Type | Description |
---|---|---|
o |
object |
Returns:
- Type
- DataRow
(inner) postingTable() → {string}
Returns the table that should be used for writing, using tableForReading as a default for tableForWriting,
or this.name if none of them is set
Returns:
- Type
- string
(inner) prepareForPosting(r, env)
This function is called before posting row into db for every insert/update
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
env |
Environment |
(inner) realTable(argopt) → {null|string}
Get/Set a table name, that represents the real table associated to the table
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
arg |
string |
<optional> |
Returns:
- Type
- null | string
(inner) rejectChanges() → {DataRow}
Discard changes, restoring the original values of the object. state becomes unchanged,
detached remains detached
Returns:
- Type
- DataRow
(inner) rejectChanges()
Reject any changes putting all to 'unchanged' state.
Added rows become detached.
(inner) rejectChanges()
Calls rejectChanges to all contained DataTables
(inner) safeAssign(r, field, value) → {*}
Assign a field assuring it will not cause duplicates on table's autoincrement fields
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
field |
string | |
value |
object |
Returns:
- Type
- *
(inner) select(filteropt) → {Array.<ObjectRow>}
Extract a set of rows matching a filter function - skipping deleted rows
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
sqlFun |
<optional> |
Returns:
- Type
- Array.<ObjectRow>
(inner) selectAll(filter) → {Array.<ObjectRow>}
Extract a set of rows matching a filter function - including deleted rows
Parameters:
Name | Type | Description |
---|---|---|
filter |
sqlFun |
Returns:
- Type
- Array.<ObjectRow>
(inner) serialize(serializeStructureopt, filterRowopt) → {object}
Creates a serializable version of this DataSet
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
serializeStructure |
boolean |
<optional> |
false | when true serialized also structure, when false only row data |
filterRow |
function |
<optional> |
function to select which rows have to be serialized |
Returns:
- Type
- object
(inner) setMaxExpr(field, expr, filter, num)
Set a value in the max cache
Parameters:
Name | Type | Description |
---|---|---|
field |
string | |
expr |
sqlFun | |
filter |
sqlFun | |
num |
int |
(inner) setOptimize(value)
Mark the table as optimized / not optimized
An optimized table has a cache for all autoincrement field
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
(inner) skipInsertCopy(argopt) → {*|boolean}
Get/Set a flag indicating that this table is not subjected to the Insert and Copy function
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
arg |
boolean |
<optional> |
Returns:
- Type
- * | boolean
(inner) skipSecurity(argopt) → {*|boolean}
Get/Set a flag indicating that this table is not subjected to security functions in a jQuery fashioned
style
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
arg |
boolean |
<optional> |
Returns:
- Type
- * | boolean
(inner) staticFilter(filteropt) → {sqlFun}
Get/Set a static filter to be used to read data from database in a Jquery fashioned style
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
sqlFun |
<optional> |
Returns:
- Type
- sqlFun
(inner) tableForReading(tableNameopt) → {*|DataTable.myTableForReading|DataTable.name}
Get/Set the name of table to be used to read data from database in a Jquery fashioned style
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tableName |
string |
<optional> |
Returns:
- Type
- * | DataTable.myTableForReading | DataTable.name
(inner) tableForWriting(tableNameopt) → {*|DataTable.myTableForWriting|DataTable.name}
Get/Set the name of table to be used to write data from database in a Jquery fashioned style
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tableName |
string |
<optional> |
Returns:
- Type
- * | DataTable.myTableForWriting | DataTable.name
(inner) toString() → {string}
Debug - helper function
Returns:
- Type
- string
(inner) toString() → {string}
Debug-helper function
Returns:
- Type
- string
(inner) updateDependencies(row, field) → {*}
Re calculate temporaryID affected by a field change. It should be done for every autoincrement field
that has that field as a selector or as a prefix field
Parameters:
Name | Type | Description |
---|---|---|
row |
ObjectRow | |
field |
string |
Returns:
- Type
- *
(inner) viewTable(argopt) → {*|string}
Get/Set a table name, that represents the view table associated to the table
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
arg |
string |
<optional> |
Returns:
- Type
- * | string