|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
ORM 对象-关系映射器 更多...
#include <sql_mapper.hpp>
静态 Public 成员函数 | |
| static string | table_name () |
| 获取映射的表名 | |
| static string | create_table_sql (string_view table_override="") |
| 生成 CREATE TABLE SQL | |
| static string | drop_table_sql (string_view table_override="") |
| 生成 DROP TABLE SQL | |
| static string | select_sql (string_view table_override="") |
| 生成 SELECT 查询 SQL | |
| static string | insert_sql (string_view table_override="", const sql_dialect dialect=sql_dialect::GENERIC) |
| 生成 INSERT SQL(占位符由方言自动决定) | |
| static string | delete_sql (string_view table_override="", const sql_dialect dialect=sql_dialect::GENERIC) |
| 生成 DELETE SQL(按主键删除) | |
| static string | update_sql (string_view table_override="", const sql_dialect dialect=sql_dialect::GENERIC) |
| 生成 UPDATE SQL(按主键更新所有非主键字段) | |
| static vector< string > | get_values (const T &entity, bool include_pk=true) |
| 从实体提取所有持久化字段的值(以 SQL 字面量表示) | |
| static reflect::meta_any | get_pk_value (const T &entity) |
| 获取主键值 | |
| static T | from_row (const idb_tb_result &row, const unordered_map< string, size_t > &col_map={}) |
| 从结果行构建实体对象 | |
| static vector< T > | from_result (unique_ptr< idb_tb_result > result) |
| 从查询结果集构建实体对象列表 | |
| static string | select_by_pk_sql (string_view table_override="", const sql_dialect dialect=sql_dialect::GENERIC) |
| 生成按主键查询的 SELECT SQL | |
ORM 对象-关系映射器
| T | 实体类型 |
通过反射元数据自动完成实体类型与数据库表之间的映射。 所有方法均为静态方法,无需实例化。
在文件 sql_mapper.hpp 第 173 行定义.
|
inlinestatic |
生成 CREATE TABLE SQL
| table_override | 可选的表名覆盖(为空则使用反射元数据的表名) |
在文件 sql_mapper.hpp 第 238 行定义.
引用了 neforce::sql_builder::build(), neforce::sql_builder::column(), neforce::sql_builder::column_auto_increment(), neforce::sql_builder::column_not_null(), neforce::sql_builder::column_primary_key(), neforce::sql_builder::column_unique(), neforce::cpp_type_to_sql_type() , 以及 neforce::sql_builder::create_table_if_not_exists().
|
inlinestatic |
生成 DELETE SQL(按主键删除)
| table_override | 可选的表名覆盖 |
| dialect | 数据库方言 |
| value_exception | 无主键属性时抛出 |
在文件 sql_mapper.hpp 第 331 行定义.
引用了 neforce::sql_builder::build(), neforce::sql_builder::delete_from(), neforce::basic_string< CharT, Traits, Alloc >::empty(), GENERIC, neforce::sql_builder::placeholder(), neforce::sql_builder::set_dialect() , 以及 neforce::sql_builder::where_eq().
|
inlinestatic |
生成 DROP TABLE SQL
| table_override | 可选的表名覆盖 |
在文件 sql_mapper.hpp 第 274 行定义.
引用了 neforce::sql_builder::build(), neforce::sql_builder::drop_table_if_exists() , 以及 neforce::basic_string< CharT, Traits, Alloc >::empty().
|
inlinestatic |
从查询结果集构建实体对象列表
| result | 查询结果集 |
在文件 sql_mapper.hpp 第 453 行定义.
引用了 from_row() , 以及 neforce::vector< T, Alloc >::push_back().
被这些函数引用 neforce::repository< T, Connect >::find_all(), neforce::repository< T, Connect >::find_page() , 以及 neforce::repository< T, Connect >::find_where().
|
inlinestatic |
从结果行构建实体对象
| row | 结果行(当前已定位到目标行) |
| col_map | 列名到列索引的映射(为空时自动按属性名匹配) |
在文件 sql_mapper.hpp 第 412 行定义.
被这些函数引用 neforce::repository< T, Connect >::find_by_id() , 以及 from_result().
|
inlinestatic |
|
inlinestatic |
从实体提取所有持久化字段的值(以 SQL 字面量表示)
| entity | 实体对象引用 |
| include_pk | 是否包含主键值 |
在文件 sql_mapper.hpp 第 382 行定义.
|
inlinestatic |
生成 INSERT SQL(占位符由方言自动决定)
| table_override | 可选的表名覆盖 |
| dialect | 数据库方言(默认 GENERIC 即 ?) |
在文件 sql_mapper.hpp 第 308 行定义.
引用了 neforce::sql_builder::build(), neforce::basic_string< CharT, Traits, Alloc >::empty(), GENERIC, neforce::sql_builder::insert_into(), neforce::vector< T, Alloc >::push_back(), neforce::vector< T, Alloc >::reserve() , 以及 neforce::sql_builder::set_dialect().
|
inlinestatic |
生成按主键查询的 SELECT SQL
| table_override | 可选的表名覆盖 |
| dialect | 数据库方言 |
在文件 sql_mapper.hpp 第 477 行定义.
引用了 neforce::sql_builder::build(), neforce::basic_string< CharT, Traits, Alloc >::empty(), neforce::sql_builder::from(), GENERIC, neforce::sql_builder::placeholder(), neforce::sql_builder::select(), neforce::sql_builder::set_dialect() , 以及 neforce::sql_builder::where_eq().
|
inlinestatic |
生成 SELECT 查询 SQL
| table_override | 可选的表名覆盖 |
在文件 sql_mapper.hpp 第 286 行定义.
引用了 neforce::sql_builder::build(), neforce::basic_string< CharT, Traits, Alloc >::empty(), neforce::sql_builder::from() , 以及 neforce::sql_builder::select().
|
inlinestatic |
获取映射的表名
在文件 sql_mapper.hpp 第 231 行定义.
被这些函数引用 neforce::repository< T, Connect >::count(), neforce::repository< T, Connect >::find_all(), neforce::repository< T, Connect >::find_by_id(), neforce::repository< T, Connect >::find_page(), neforce::repository< T, Connect >::find_where() , 以及 neforce::repository< T, Connect >::table_exists().
|
inlinestatic |
生成 UPDATE SQL(按主键更新所有非主键字段)
| table_override | 可选的表名覆盖 |
| dialect | 数据库方言 |
| value_exception | 无主键属性时抛出 |
在文件 sql_mapper.hpp 第 352 行定义.
引用了 neforce::sql_builder::build(), neforce::basic_string< CharT, Traits, Alloc >::empty(), GENERIC, neforce::sql_builder::next_placeholder(), neforce::sql_builder::set_dialect(), neforce::sql_builder::set_param(), neforce::sql_builder::update() , 以及 neforce::sql_builder::where_eq().