Documentation for the "fieldUpdaters" JSON key.
Field updaters are a simple way to generate singular updaters that update a single field for either the complete table, or a specific row identified by its primary key.
The key fieldUpdaters is a JSON Array of JSON Objects on the table JSON object, for example:
"tables": [
{
"fields": [
...
],
"fieldUpdaters": [
...
]
}
]
Adding the following fieldUpdaters JSON array of JSON Objects:
"fieldUpdaters": [
{ "fl_is_indexed": "unique" },
{ "fl_is_alive": "multiple" }
]
Assuming that the primary key is named id_user
unique updaters: The name of the updater will be update<CamelCaseFieldName>By<CamelCase<PrimaryKeyFieldName>>
multiple updaters: The name of the updater will be update<CamelCaseFieldName>
This will automatically generate two updaters:
- The first updater is
updateFlIsIndexedByIdUserwhich will return the number of rows updated (which should always by one) with two parameters passed into the method, namelyflIsIndexed, andidUser. - The second updater is
updateFlIsAlive. which will the number of rows updated and has one parameter passed into the method, namelyflIsAlive.
The alternate way to define the above updaters is as follows (which would generate identical code):
"updaters": [
{
"name": "updateFlIsIndexedByIdUser",
"setClause": "set fl_is_indexed = ?"",
"setFields": [
"fl_is_indexed"
],
"whereClause": "where id_user = ?",
"whereFields": [
"id_user"
]
},
{
"name": "updateFlIsAlive",
"setClause": "set fl_is_alive = ?"",
"setFields": [
"fl_is_alive"
]
}
]
Which as you can see is a lot more work, more prone to error and un-necessary for something that can be automatically generated.