Model Variables

The following variables are used in the Model class. You can setup their values in component.json.

{
...
  "current_table": "product",
  "current_key"  : "product_id",
  "current_id_auto" : "product_id",
  "key_in"       : {"table1" : "fk", "table2" : "fk"},
  "insert_pars"  : ["title", "description", "price", "category_id"],
  "topics_pars"  : ["product_id", "title", "price", "category_id"],
  "edit_pars"    : ["product_id", "title", "description", "price", "category_id"],
  "update_pars"  : ["product_id", "title", "description", "price", "category_id"],
  "empties"      : ["description"],
...
}

Here is the list of attributes for the database table.

  • current_table: the table name.
  • current_key: the primary key (PK). If it consists of several fields,  assign them to current_keys as an array.
  • current_id_auto: if there is an auto increment field, put it here.
  • key_in: if to delete an item using the PK, and if this PK exists in other tables as foreign key, Genelet will stop the deletion. This object defines those tables and the column names of the PK there.

Here is the list of attributes for RESTful or CRUD.

  • insert_pars: array, defining which fields will be inserted.
  • topics_pars: array, defining which fields will be searched for in the “list_all” RESTful request.
  • edit_pars: array, defining which fields will be selected for specific item.
  • update_pars: array, defining which fields will be updated.
  • empties: array. During update, fields without input will be untouched. By defining those fields in empties, they will be force to be NULL instead.
  • insupd_pars: array, defining unique column names, whose existence will make Genelet’s special verb insupd, to be update, while non existence will make it to be insert.