Skip to content

Commit 529cf5b

Browse files
Pierre-Luc GagnéCopilot
andcommitted
docs: add COLUMN_FIELD macro example to README
Shows the macro as a convenient shorthand for the verbose tag struct + type alias + member variable pattern in the Quick Start section. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b09f5f9 commit 529cf5b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ struct product {
4040
price price_;
4141
};
4242

43+
// Alternatively, use the COLUMN_FIELD macro to reduce boilerplate:
44+
struct product_v2 {
45+
COLUMN_FIELD(id, uint32_t);
46+
COLUMN_FIELD(sku, varchar_field<64>);
47+
COLUMN_FIELD(name, varchar_field<255>);
48+
COLUMN_FIELD(price, double);
49+
};
50+
// Each COLUMN_FIELD(tag, type) expands to: a tag struct, a type alias, and a member variable.
51+
// The two definitions are equivalent and produce the same SQL schema.
52+
4353
// 2. Connect and query
4454
auto db = mysql_database::connect(mysql_config{
4555
host_name{"127.0.0.1"},

0 commit comments

Comments
 (0)