Create and Update API
save
Saves the entity passed as input to the database
DSApi.save(className, entity)
or
DSApi.save(className, entity, auditMsg)
Parameters
className: the str name of class as created using the workbench
(correspond to the table)
entity: dictionary
auditMsg: str
Sample Code
className = "shared.common.product"
entity = {"productName" : "table", "description" : "foldable table", "prices" : 620}
res = DSApi.save(className, entity)
Returns
A Result object indicating the success or failure of the save operation.
saveMany
Saves the list of entities to the database
DSApi.saveMany(className, entities)
or
DSApi.saveMany(className, entities, auditMsg)
Parameters
className: the str name of class as created using the workbench
(correspond to the table)
entity: Iterable<Object>
Sample Code
className = 'shared.common.product'
entities = []
entity = {"productName" : "table", "description" : "foldable table", "prices" : 620}
entities.append(entity)
res = DSApi.save(className, entities)
Returns
A Result object indicating the success or failure of the save operation.
Update
Updates the attribute name with the provided value
DSApi.update(className, id, attrName, value)
or
DSApi.update(className, id, attrName, value, auditMsg)
Parameters
className: the name of class as created using the workbench
(correspond to the table)
id: str
attrName: str
value: obj
auditMsg: str
Sample Code
className = "shared.common.product"
id = "12"
attrName = "price"
value = 700
res = DSApi.update(className, id, attrName, value)
Returns
A Result object indicating the success or failure of the update operation.
UpdateMany
Update many records at a time. The class name is provided that indirectly represents a table. β
DSApi.updateMany(className, ids, attrName, value)
or
DSApi.updateMany(className, ids, attrName, value, auditMsg)
Parameters
className: the str name of class as created using the workbench
(correspond to the table)
ids: List<String> rows needed to be modified
attrName: the name of the column as str
value: the Object value of inside the column for the specific row
auditMsg: any informational message as str
Sample Code
className = "shared.common.product"
ids = ["12", "15"]
attrName = "price"
value = 700
res = DSApi.updateMany(className, ids, attrName, value)
Returns
A Result object indicating the success or failure of the update operation.
UpdateByQuery
Update by executing a query on the table. βit takes partial query which is the embellished with where clauses.
DSApi.updateByQuery(className, query, updateAttrs)
or
DSApi.updateByQuery(className, query, updateAttrs, auditMsg)
Parameters
className: the str name of class as created using the workbench
(correspond to the table)
query: the str type query represents the filtering criteria
updateAttrs: update dictionary for the attributes
auditMsg: a str type informational message
Sample Code
className = "shared.common.product"
updateParam = {"deleted": True}
res = DSApi.updateByQuery(className, "", updateParam)
Returns
A Result object indicating the success or failure of the update operation.
executeSqlWriteStatement
Execute a stored procedure or SQL string. The statement is prepared for execution.β Use this method when you're specifying the full statement.
DSApi.executeSqlWriteStatement(dsName, sqlStatement, params)
Parameters
dsName: the name of the data source
sqlStatement: SQL String
params: parameter values to be replaced inside the string
Returns
A Result object containing the execution result.
Last updated