Rudiments
|
#include <mvc.h>
Inherits object.
Protected Member Functions | |
virtual const char * | deriveDataType (const char *value) |
The mvccrud class defines an interface for child classes which implement the CRUD (create, read, update, and delete) paradigm.
A typical invocation of a mycrud class which implements mvccrud, from within the dao tier of an MVC application, would be something like:
// initialize crud mycrud *crud=new mycrud(); mycrud->init(...some init parameters...);
// read data mycrud->doRead(...);
// return results via instance of mvcresults mvcr->setSuccess(); mvcr->attachData("myresults","table",mycrud->getResultSetTable()); mvcr->getWastebasket()->attach(crud);
Various methods such as doRead(), doUpdate(), and doDelete() take a "criteria" argument. This should be a JSON string in jsonlogic format (http://jsonlogic.com), and will be used to constrain the results.
{ "and" : [ { "=" : [ { "var" : "col1" }, 1 ] }, { "!=" : [ { "var" : "col2" }, "one" ] } ] }
The doRead() method also takes a "sort" argument. This should be a JSON string conforming to the following format, and will be used to order the results.
{ "col1" : "asc", "col2" : "asc", "col3" : "desc" }
Returns "u" if "value" is NULL, "n" if value is a numeric string, and "s" otherwise.
Executes a create (insert) operation.
"columns" should contain the set of columns that corresponding elements of "values" will be inserted into. The data type of each value will be derived as "s", "n", or "u" from the value.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
pure virtual |
Executes a create (insert) operation.
"columns" should contain the set of columns that corresponding elements of "values" will be inserted into.
"types" should contain the corresponding data type for each value:
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes a create (insert) operation.
Keys of "kvp" and values of "kvp" should be set to the column/value pairs to be inserted. The data type of each value will be derived as "s", "n", or "u" from the value.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes a create (insert) operation.
"j" should be a jsondom containing 1 object:
"data" should be a JSON object consisting of the column/value pairs to be inserted.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes a delete operation.
"criteria" should be a JSON string representing the criteria that will be used to determine what to delete, conforming to the format described in the class description.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes a delete operation.
"j" should be a jsondom containing 1 object:
"criteria" should be a JSON object representing the criteria that will be used to determine what to delete, conforming to the format described in the class description.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
pure virtual |
Executes a read operation.
"criteria" should be a JSON string representing the criteria that will be used to constrain the results, conforming to the format described in the class description.
"sort" should be a JSON object representing the criteria that will be used to order the results, conforming to the format described in the class description.
"skip" indicates how many rows to skip immediately (useful for paging).
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes a read operation.
"j" should be a jsondom containing 3 objects:
"criteria" should be a JSON object representing the criteria that will be used to determine what to read, conforming to the format described in the class description.
"sort" should be a JSON object representing the criteria that will be used to order the results, conforming to the format described in the class description.
"skip" should be a number indicating how many rows to skip immediately (useful for paging).
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
pure virtual |
Executes an update operation.
"columns" and "values" should be set to the column/value pairs to be updated. "types" should be set to the corresponding data type for each value:
"criteria" should be a JSON string representing the criteria that will be used to determine what to update, conforming to the format described in the class description.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
inlinevirtual |
Executes an update operation.
"columns" and "values" should be set to the column/value pairs to be updated. The data type of each value will be derived as "s", "n", or "u" from the value.
"criteria" should be a JSON string representing the criteria that will be used to determine what to update, conforming to the format described in the class description.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
pure virtual |
Executes an update operation.
Keys of "kvp" and values of "kvp" should be set to the column/value pairs to be updated. The data type of each value will be derived as "s", "n", or "u" from the value.
"criteria" should be a JSON string representing the criteria that will be used to determine what to update, conforming to the format described in the class description.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
Executes an update operation.
"j" should be a jsondom containing 2 objects:
"criteria" should be a JSON object representing the criteria that will be used to determine what to update, conforming to the format described in the class description.
"data" should be a JSON object consisting of the column/value pairs to be updated.
Returns true on success and false on error. On error, the code and message can be retrieved using getErrorCode() and getErrorMessage().
|
pure virtual |
Returns an instance of dictionarycollection with a single element, containing the affected rows doCreate(), doUpdate(), or doDelete() was most recently called or an empty dictionary if doRead() was most recently called.
|
pure virtual |
Returns an instance of listcollection with a single element, containing the affected rows doCreate(), doUpdate(), or doDelete() was most recently called or an empty list if doRead() was most recently called.
|
pure virtual |
Returns an instance of scalarcollection, containing the number of affected rows if doCreate(), doUpdate(), or doDelete() was most recently called or an empty scalar if doRead() was most recently called.
|
pure virtual |
Returns an instance of tablecollection with a single field, containing the affected rows doCreate(), doUpdate(), or doDelete() was most recently called or an empty table if doRead() was most recently called.
|
pure virtual |
Returns whatever error code may have been set by the most recent failed method call.
Returns whatever error message may have been set by the most recent failed method call.
|
pure virtual |
Returns an instance of dictionarycollection, representing the first column of each row of the results if doRead() was most recently called, or an empty dictionary if doCreate(), doUpdate(), or doDelete() was most recently called.
|
pure virtual |
Returns an instance of scalarcollection, representing the first field of the first row of the results if doRead() was most recently called, or an empty scalar if doCreate(), doUpdate(), or doDelete() was most recently called.
|
pure virtual |
Returns an instance of dictionarycollection, representing the first row of the results if doRead() was most recently called, or an empty dictionary if doCreate(), doUpdate(), or doDelete() was most recently called.
|
pure virtual |
Returns an instance of listcollection, representing the first row of the results if doRead() was most recently called, or an empty list if doCreate(), doUpdate(), or doDelete() was most recently called.
|
pure virtual |
Returns an instance of tablecollection, representing the results if doRead() was most recently called, or an empty resultsettable if doCreate(), doUpdate(), or doDelete() was most recently called.