model.json 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. //rdbms: server type, postgresql,mysql or sqlite3
  3. "rdbms": "postgresql",
  4. //filename: sqlite3 db file name
  5. //"filename":"",
  6. //host: server address,localhost by default;
  7. "host": "127.0.0.1",
  8. //port: server port, 5432 by default;
  9. "port": 5432,
  10. //dbname: Database name;
  11. "dbname": "",
  12. //schema: valid for postgreSQL, "public" by default;
  13. "schema": "public",
  14. //user: User name
  15. "user": "",
  16. //password or passwd: Password
  17. "password": "",
  18. //client_encoding: The character set used by drogon_ctl. it is empty string by default which
  19. //means use the default character set.
  20. //"client_encoding": "",
  21. //table: An array of tables to be modelized. if the array is empty, all revealed tables are modelized.
  22. "tables": [],
  23. //convert: the value can be changed by a function call before it is stored into database or
  24. //after it is read from database
  25. "convert": {
  26. "enabled": false,
  27. "items":[{
  28. "table": "user",
  29. "column": "password",
  30. "method": {
  31. //after_db_read: name of the method which is called after reading from database, signature: void([const] std::shared_ptr [&])
  32. "after_db_read": "decrypt_password",
  33. //before_db_write: name of the method which is called before writing to database, signature: void([const] std::shared_ptr [&])
  34. "before_db_write": "encrypt_password"
  35. },
  36. "includes": [
  37. "\"file_local_search_path.h\"","<file_in_global_search_path.h>"
  38. ]
  39. }]
  40. },
  41. "relationships": {
  42. "enabled": false,
  43. "items": [{
  44. "type": "has one",
  45. "original_table_name": "products",
  46. "original_table_alias": "product",
  47. "original_key": "id",
  48. "target_table_name": "skus",
  49. "target_table_alias": "SKU",
  50. "target_key": "product_id",
  51. "enable_reverse": true
  52. },
  53. {
  54. "type": "has many",
  55. "original_table_name": "products",
  56. "original_table_alias": "product",
  57. "original_key": "id",
  58. "target_table_name": "reviews",
  59. "target_table_alias": "",
  60. "target_key": "product_id",
  61. "enable_reverse": true
  62. },
  63. {
  64. "type": "many to many",
  65. "original_table_name": "products",
  66. "original_table_alias": "",
  67. "original_key": "id",
  68. "pivot_table": {
  69. "table_name": "carts_products",
  70. "original_key": "product_id",
  71. "target_key": "cart_id"
  72. },
  73. "target_table_name": "carts",
  74. "target_table_alias": "",
  75. "target_key": "id",
  76. "enable_reverse": true
  77. }
  78. ]
  79. },
  80. "restful_api_controllers": {
  81. "enabled": false,
  82. // resource_uri: The URI to access the resource, the default value
  83. // is '/*' in which the asterisk represents the table name.
  84. // If this option is set to a empty string, the URI is composed of the namespaces and the class name.
  85. "resource_uri": "/*",
  86. // class_name: "Restful*Ctrl" by default, the asterisk represents the table name.
  87. // This option can contain namespaces.
  88. "class_name": "Restful*Ctrl",
  89. // filters: an array of filter names.
  90. "filters": [],
  91. // db_client: the database client used by the controller. this option must be consistent with
  92. // the configuration of the application.
  93. "db_client": {
  94. //name: Name of the client,'default' by default
  95. "name": "default",
  96. //is_fast:
  97. "is_fast": false
  98. },
  99. // directory: The directory where the controller source files are stored.
  100. "directory": "controllers",
  101. // generate_base_only: false by default. Set to true to avoid overwriting custom subclasses.
  102. "generate_base_only": false
  103. }
  104. }