meadow-connection-mysql 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -1
- package/README.md +14 -14
- package/docs/README.md +2 -2
- package/docs/_brand.json +18 -0
- package/docs/_cover.md +1 -1
- package/docs/_sidebar.md +8 -8
- package/docs/_topbar.md +1 -1
- package/docs/_version.json +3 -3
- package/docs/api/reference.md +1 -1
- package/docs/architecture.md +14 -154
- package/docs/diagrams/configuration-coercion.excalidraw +1843 -0
- package/docs/diagrams/configuration-coercion.mmd +28 -0
- package/docs/diagrams/configuration-coercion.svg +2 -0
- package/docs/diagrams/configuration-pipeline.excalidraw +3174 -0
- package/docs/diagrams/configuration-pipeline.mmd +15 -0
- package/docs/diagrams/configuration-pipeline.svg +2 -0
- package/docs/diagrams/connection-lifecycle.excalidraw +2190 -0
- package/docs/diagrams/connection-lifecycle.mmd +30 -0
- package/docs/diagrams/connection-lifecycle.svg +2 -0
- package/docs/diagrams/ddl-generation-flow.excalidraw +3285 -0
- package/docs/diagrams/ddl-generation-flow.mmd +15 -0
- package/docs/diagrams/ddl-generation-flow.svg +2 -0
- package/docs/diagrams/double-connect-prevention.excalidraw +1420 -0
- package/docs/diagrams/double-connect-prevention.mmd +7 -0
- package/docs/diagrams/double-connect-prevention.svg +2 -0
- package/docs/diagrams/meadow-integration.excalidraw +1543 -0
- package/docs/diagrams/meadow-integration.mmd +18 -0
- package/docs/diagrams/meadow-integration.svg +2 -0
- package/docs/diagrams/system-architecture.excalidraw +1773 -0
- package/docs/diagrams/system-architecture.mmd +27 -0
- package/docs/diagrams/system-architecture.svg +2 -0
- package/docs/index.html +6 -7
- package/docs/retold-catalog.json +138 -150
- package/docs/retold-keyword-index.json +5623 -2241
- package/package.json +8 -8
- package/source/Meadow-Connection-MySQL.js +17 -0
- package/source/Meadow-Schema-MySQL.js +30 -0
- package/docs/css/docuserve.css +0 -327
package/CONTRIBUTING.md
CHANGED
|
@@ -47,4 +47,4 @@ When in doubt, match what the surrounding code does.
|
|
|
47
47
|
|
|
48
48
|
## Repository Structure
|
|
49
49
|
|
|
50
|
-
Each module is its own git repository. The [retold](https://github.com/
|
|
50
|
+
Each module is its own git repository. The [retold](https://github.com/fable-retold/retold) repository tracks module organization but does not contain module source code. Direct your pull request to the specific module repository where your change belongs.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Meadow Connection MySQL
|
|
2
2
|
|
|
3
|
+
> **[Read the Meadow-Connection-Mysql Documentation](https://fable-retold.github.io/meadow-connection-mysql/)** - interactive docs with the full API reference.
|
|
4
|
+
|
|
3
5
|
A MySQL connection pool provider for the Meadow ORM. Wraps [mysql2](https://github.com/sidorares/node-mysql2) as a Fable service, providing connection pooling with named placeholders, auto-connect support, and DDL generation from Meadow table schemas.
|
|
4
6
|
|
|
5
|
-
[
|
|
6
|
-
[](https://badge.fury.io/js/meadow-connection-mysql)
|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[meadow-connection-mysql on npm](https://www.npmjs.com/package/meadow-connection-mysql) | [MIT License](LICENSE)
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -167,13 +167,13 @@ Generate a `DROP TABLE IF EXISTS` SQL statement for the given table name.
|
|
|
167
167
|
|
|
168
168
|
Meadow Connection MySQL is a database connector for the Meadow data access layer:
|
|
169
169
|
|
|
170
|
-
- [meadow](https://github.com/
|
|
171
|
-
- [foxhound](https://github.com/
|
|
172
|
-
- [stricture](https://github.com/
|
|
173
|
-
- [meadow-endpoints](https://github.com/
|
|
174
|
-
- [meadow-connection-mssql](https://github.com/
|
|
175
|
-
- [meadow-connection-sqlite](https://github.com/
|
|
176
|
-
- [fable](https://github.com/
|
|
170
|
+
- [meadow](https://github.com/fable-retold/meadow) -- ORM and data access framework
|
|
171
|
+
- [foxhound](https://github.com/fable-retold/foxhound) -- Query DSL used by Meadow
|
|
172
|
+
- [stricture](https://github.com/fable-retold/stricture) -- Schema definition tool
|
|
173
|
+
- [meadow-endpoints](https://github.com/fable-retold/meadow-endpoints) -- RESTful endpoint generation
|
|
174
|
+
- [meadow-connection-mssql](https://github.com/fable-retold/meadow-connection-mssql) -- MSSQL connector
|
|
175
|
+
- [meadow-connection-sqlite](https://github.com/fable-retold/meadow-connection-sqlite) -- SQLite connector
|
|
176
|
+
- [fable](https://github.com/fable-retold/fable) -- Application services framework
|
|
177
177
|
|
|
178
178
|
## Testing
|
|
179
179
|
|
|
@@ -191,9 +191,9 @@ npm run coverage
|
|
|
191
191
|
|
|
192
192
|
## Related Packages
|
|
193
193
|
|
|
194
|
-
- [meadow](https://github.com/
|
|
195
|
-
- [meadow-connection-rocksdb](https://github.com/
|
|
196
|
-
- [fable](https://github.com/
|
|
194
|
+
- [meadow](https://github.com/fable-retold/meadow) -- Data access and ORM
|
|
195
|
+
- [meadow-connection-rocksdb](https://github.com/fable-retold/meadow-connection-rocksdb) -- RocksDB connection provider
|
|
196
|
+
- [fable](https://github.com/fable-retold/fable) -- Application services framework
|
|
197
197
|
|
|
198
198
|
## License
|
|
199
199
|
|
|
@@ -201,4 +201,4 @@ MIT
|
|
|
201
201
|
|
|
202
202
|
## Contributing
|
|
203
203
|
|
|
204
|
-
Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/
|
|
204
|
+
Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/fable-retold/retold/blob/main/docs/contributing.md).
|
package/docs/README.md
CHANGED
|
@@ -176,5 +176,5 @@ Meadow Connection MySQL sits between the Meadow ORM layer and the MySQL server.
|
|
|
176
176
|
- [Architecture](architecture.md) -- Design, data flow, and component responsibilities
|
|
177
177
|
- [Schema & Table Creation](schema.md) -- Generate MySQL tables from Meadow schemas
|
|
178
178
|
- [API Reference](api/reference.md) -- Complete method and property documentation
|
|
179
|
-
- [Meadow](/meadow/
|
|
180
|
-
- [FoxHound](/
|
|
179
|
+
- [Meadow](https://fable-retold.github.io/meadow/) -- The data access layer
|
|
180
|
+
- [FoxHound](https://fable-retold.github.io/foxhound/) -- Query DSL used by Meadow
|
package/docs/_brand.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "meadow-connection-mysql",
|
|
3
|
+
"Name": "Meadow Connection Mysql",
|
|
4
|
+
"Tagline": "MySQL and MariaDB pooled connection provider for Meadow",
|
|
5
|
+
"Palette": "mix",
|
|
6
|
+
"Icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"frame-meadow-connection-mysql-filled-light\">\n\t\t\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\" fill=\"#b46a2e\"/>\n\t\t<g clip-path=\"url(#frame-meadow-connection-mysql-filled-light)\"><path d=\"M 16 70 L 48 30 L 80 70 Z\" fill=\"rgba(255,255,255,0.18)\"/>\n\t\t\t\t\t<path d=\"M 24 80 L 48 52 L 72 80 Z\" fill=\"#50c7cc\" opacity=\"0.9\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"28\" font-weight=\"700\"\n\t\t\tfill=\"#ffffff\" letter-spacing=\"-1\">MCM</text>\n\t</svg>",
|
|
7
|
+
"IconType": "svg",
|
|
8
|
+
"Favicon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"fav-meadow-connection-mysql-light\">\n\t\t\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\" fill=\"#b46a2e\"/>\n\t\t<g clip-path=\"url(#fav-meadow-connection-mysql-light)\"><path d=\"M 16 70 L 48 30 L 80 70 Z\" fill=\"rgba(255,255,255,0.22)\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"60\" font-weight=\"800\"\n\t\t\tfill=\"#ffffff\" letter-spacing=\"-1\">M</text>\n\t</svg>",
|
|
9
|
+
"FaviconDark": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"fav-meadow-connection-mysql-dark\">\n\t\t\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 24 2\n\t\tH 72\n\t\tQ 94 2 94 24\n\t\tV 72\n\t\tQ 94 94 72 94\n\t\tH 24\n\t\tQ 2 94 2 72\n\t\tV 24\n\t\tQ 2 2 24 2 Z\" fill=\"#d2996b\"/>\n\t\t<g clip-path=\"url(#fav-meadow-connection-mysql-dark)\"><path d=\"M 16 70 L 48 30 L 80 70 Z\" fill=\"rgba(255,255,255,0.22)\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"60\" font-weight=\"800\"\n\t\t\tfill=\"#101418\" letter-spacing=\"-1\">M</text>\n\t</svg>",
|
|
10
|
+
"Colors": {
|
|
11
|
+
"Primary": "#b46a2e",
|
|
12
|
+
"Secondary": "#50c7cc",
|
|
13
|
+
"PrimaryLight": "#b46a2e",
|
|
14
|
+
"PrimaryDark": "#d2996b",
|
|
15
|
+
"SecondaryLight": "#50c7cc",
|
|
16
|
+
"SecondaryDark": "#9bdadc"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/docs/_cover.md
CHANGED
|
@@ -16,4 +16,4 @@ A lightweight wrapper around [mysql2](https://github.com/sidorares/node-mysql2)
|
|
|
16
16
|
[Architecture](architecture.md)
|
|
17
17
|
[Schema & Tables](schema.md)
|
|
18
18
|
[API Reference](api/reference.md)
|
|
19
|
-
[GitHub](https://github.com/
|
|
19
|
+
[GitHub](https://github.com/fable-retold/meadow-connection-mysql)
|
package/docs/_sidebar.md
CHANGED
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
|
|
22
22
|
- Retold Ecosystem
|
|
23
23
|
|
|
24
|
-
- [Meadow](/meadow/
|
|
25
|
-
- [FoxHound](/
|
|
26
|
-
- [Stricture](/
|
|
27
|
-
- [Meadow Endpoints](/meadow
|
|
28
|
-
- [Meadow Connection MSSQL](/meadow
|
|
29
|
-
- [Meadow Connection SQLite](/meadow
|
|
30
|
-
- [Meadow Connection RocksDB](/meadow
|
|
31
|
-
- [Fable](
|
|
24
|
+
- [Meadow](https://fable-retold.github.io/meadow/)
|
|
25
|
+
- [FoxHound](https://fable-retold.github.io/foxhound/)
|
|
26
|
+
- [Stricture](https://fable-retold.github.io/stricture/)
|
|
27
|
+
- [Meadow Endpoints](https://fable-retold.github.io/meadow-endpoints/)
|
|
28
|
+
- [Meadow Connection MSSQL](https://fable-retold.github.io/meadow-connection-mssql/)
|
|
29
|
+
- [Meadow Connection SQLite](https://fable-retold.github.io/meadow-connection-sqlite/)
|
|
30
|
+
- [Meadow Connection RocksDB](https://fable-retold.github.io/meadow-connection-rocksdb/)
|
|
31
|
+
- [Fable](https://fable-retold.github.io/fable/)
|
package/docs/_topbar.md
CHANGED
package/docs/_version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Name": "meadow-connection-mysql",
|
|
3
|
-
"Version": "1.0.
|
|
3
|
+
"Version": "1.0.19",
|
|
4
4
|
"Description": "Meadow MySQL Plugin",
|
|
5
|
-
"GeneratedAt": "2026-
|
|
6
|
-
"GitCommit": "
|
|
5
|
+
"GeneratedAt": "2026-05-26T21:12:29.527Z",
|
|
6
|
+
"GitCommit": "ea910fe"
|
|
7
7
|
}
|
package/docs/api/reference.md
CHANGED
|
@@ -6,7 +6,7 @@ Complete method and property documentation for `MeadowConnectionMySQL`.
|
|
|
6
6
|
|
|
7
7
|
## Class: MeadowConnectionMySQL
|
|
8
8
|
|
|
9
|
-
Extends `FableServiceProviderBase` from [fable-serviceproviderbase](https://github.
|
|
9
|
+
Extends `FableServiceProviderBase` from [fable-serviceproviderbase](https://fable-retold.github.io/fable-serviceproviderbase/).
|
|
10
10
|
|
|
11
11
|
```javascript
|
|
12
12
|
const libMeadowConnectionMySQL = require('meadow-connection-mysql');
|
package/docs/architecture.md
CHANGED
|
@@ -6,35 +6,8 @@ Meadow Connection MySQL bridges the Meadow data access layer and the MySQL datab
|
|
|
6
6
|
|
|
7
7
|
## System Architecture
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
subgraph Application
|
|
12
|
-
A[Application Code]
|
|
13
|
-
B[Meadow ORM]
|
|
14
|
-
C[FoxHound Query DSL]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
subgraph MeadowConnectionMySQL["Meadow Connection MySQL"]
|
|
18
|
-
D[MeadowConnectionMySQL Service]
|
|
19
|
-
E[Configuration Coercion]
|
|
20
|
-
F[mysql2 Connection Pool]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
subgraph Database["MySQL Server"]
|
|
24
|
-
G[MySQL / MariaDB]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
A -->|doCreate / doRead / doUpdate / doDelete| B
|
|
28
|
-
B -->|setProvider MySQL| C
|
|
29
|
-
C -->|SQL + Parameters| D
|
|
30
|
-
D -->|Settings| E
|
|
31
|
-
E -->|Coerced Config| F
|
|
32
|
-
F -->|TCP Connections| G
|
|
33
|
-
|
|
34
|
-
style MeadowConnectionMySQL fill:#e8f4f8,stroke:#2E7D74,stroke-width:2px
|
|
35
|
-
style Application fill:#f5f0e8,stroke:#423D37,stroke-width:1px
|
|
36
|
-
style Database fill:#fef3e2,stroke:#c97a2e,stroke-width:1px
|
|
37
|
-
```
|
|
9
|
+
<!-- bespoke diagram: edit diagrams/system-architecture.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
10
|
+

|
|
38
11
|
|
|
39
12
|
---
|
|
40
13
|
|
|
@@ -53,36 +26,8 @@ The core class, extending `FableServiceProviderBase`. It manages the lifecycle o
|
|
|
53
26
|
|
|
54
27
|
The constructor translates between two naming conventions:
|
|
55
28
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
subgraph Meadow Style
|
|
59
|
-
A1["Server"]
|
|
60
|
-
A2["Port"]
|
|
61
|
-
A3["User"]
|
|
62
|
-
A4["Password"]
|
|
63
|
-
A5["Database"]
|
|
64
|
-
A6["ConnectionPoolLimit"]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
subgraph mysql2 Native
|
|
68
|
-
B1["host"]
|
|
69
|
-
B2["port"]
|
|
70
|
-
B3["user"]
|
|
71
|
-
B4["password"]
|
|
72
|
-
B5["database"]
|
|
73
|
-
B6["connectionLimit"]
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
A1 --> B1
|
|
77
|
-
A2 --> B2
|
|
78
|
-
A3 --> B3
|
|
79
|
-
A4 --> B4
|
|
80
|
-
A5 --> B5
|
|
81
|
-
A6 --> B6
|
|
82
|
-
|
|
83
|
-
style Meadow Style fill:#f5f0e8,stroke:#423D37
|
|
84
|
-
style mysql2 Native fill:#e8f4f8,stroke:#2E7D74
|
|
85
|
-
```
|
|
29
|
+
<!-- bespoke diagram: edit diagrams/configuration-coercion.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
30
|
+

|
|
86
31
|
|
|
87
32
|
The Meadow-style format is the standard convention used across Retold modules. The camelCase format is what mysql2 expects natively. Both are accepted -- the constructor detects which format is present and coerces as needed.
|
|
88
33
|
|
|
@@ -99,38 +44,8 @@ The underlying pool managed by [mysql2](https://github.com/sidorares/node-mysql2
|
|
|
99
44
|
|
|
100
45
|
## Connection Lifecycle
|
|
101
46
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
participant App as Application
|
|
105
|
-
participant Fable as Fable Instance
|
|
106
|
-
participant MCS as MeadowConnectionMySQL
|
|
107
|
-
participant Pool as mysql2 Pool
|
|
108
|
-
participant MySQL as MySQL Server
|
|
109
|
-
|
|
110
|
-
App->>Fable: new libFable(config)
|
|
111
|
-
App->>Fable: addServiceType('MeadowMySQLProvider', ...)
|
|
112
|
-
App->>Fable: instantiateServiceProvider('MeadowMySQLProvider')
|
|
113
|
-
Fable->>MCS: constructor(fable, manifest, hash)
|
|
114
|
-
MCS->>MCS: Coerce config (PascalCase -> camelCase)
|
|
115
|
-
MCS->>MCS: Force namedPlaceholders = true
|
|
116
|
-
|
|
117
|
-
alt Auto-Connect Enabled
|
|
118
|
-
MCS->>MCS: connect()
|
|
119
|
-
MCS->>Pool: mysql2.createPool(settings)
|
|
120
|
-
Pool->>MySQL: Establish TCP connections
|
|
121
|
-
MCS-->>MCS: connected = true
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
App->>MCS: connect() or connectAsync()
|
|
125
|
-
MCS->>Pool: mysql2.createPool(settings)
|
|
126
|
-
Pool->>MySQL: Establish TCP connections
|
|
127
|
-
MCS-->>App: Pool ready (callback or sync)
|
|
128
|
-
|
|
129
|
-
App->>Pool: pool.query(sql, params, callback)
|
|
130
|
-
Pool->>MySQL: Execute query
|
|
131
|
-
MySQL-->>Pool: Result set
|
|
132
|
-
Pool-->>App: (error, rows, fields)
|
|
133
|
-
```
|
|
47
|
+
<!-- bespoke diagram: edit diagrams/connection-lifecycle.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
48
|
+

|
|
134
49
|
|
|
135
50
|
---
|
|
136
51
|
|
|
@@ -142,23 +57,8 @@ Settings flow through a priority chain:
|
|
|
142
57
|
2. **Fable settings** -- If no per-instance `MySQL` object is present, the constructor reads `fable.settings.MySQL` and builds the config from PascalCase properties.
|
|
143
58
|
3. **Auto-connect flag** -- Checked in both per-instance options and Fable settings. If `MeadowConnectionMySQLAutoConnect` is true in either location, `connect()` is called during construction.
|
|
144
59
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
A[Constructor Called] --> B{options.MySQL exists?}
|
|
148
|
-
B -->|Yes| C[Use options.MySQL directly]
|
|
149
|
-
B -->|No| D{fable.settings.MySQL exists?}
|
|
150
|
-
D -->|Yes| E[Build config from fable.settings]
|
|
151
|
-
D -->|No| F[No MySQL config available]
|
|
152
|
-
C --> G{Has PascalCase props?}
|
|
153
|
-
G -->|Yes| H[Coerce to camelCase]
|
|
154
|
-
G -->|No| I[Use as-is]
|
|
155
|
-
H --> J[Force namedPlaceholders = true]
|
|
156
|
-
I --> J
|
|
157
|
-
E --> J
|
|
158
|
-
J --> K{AutoConnect enabled?}
|
|
159
|
-
K -->|Yes| L[Call connect immediately]
|
|
160
|
-
K -->|No| M[Wait for explicit connect call]
|
|
161
|
-
```
|
|
60
|
+
<!-- bespoke diagram: edit diagrams/configuration-pipeline.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
61
|
+

|
|
162
62
|
|
|
163
63
|
---
|
|
164
64
|
|
|
@@ -166,23 +66,8 @@ flowchart TD
|
|
|
166
66
|
|
|
167
67
|
The `generateCreateTableStatement()` method walks a Meadow table schema and produces MySQL DDL:
|
|
168
68
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
A[Meadow Table Schema] --> B[Walk Columns Array]
|
|
172
|
-
B --> C{DataType?}
|
|
173
|
-
C -->|ID| D["INT UNSIGNED NOT NULL AUTO_INCREMENT"]
|
|
174
|
-
C -->|GUID| E["CHAR(Size) DEFAULT '0xDe'"]
|
|
175
|
-
C -->|ForeignKey| F["INT UNSIGNED NOT NULL DEFAULT '0'"]
|
|
176
|
-
C -->|Numeric| G["INT NOT NULL DEFAULT '0'"]
|
|
177
|
-
C -->|Decimal| H["DECIMAL(Size)"]
|
|
178
|
-
C -->|String| I["CHAR(Size) NOT NULL DEFAULT ''"]
|
|
179
|
-
C -->|Text| J["TEXT"]
|
|
180
|
-
C -->|DateTime| K["DATETIME"]
|
|
181
|
-
C -->|Boolean| L["TINYINT NOT NULL DEFAULT '0'"]
|
|
182
|
-
D --> M[Set PRIMARY KEY]
|
|
183
|
-
F --> M
|
|
184
|
-
M --> N["CREATE TABLE IF NOT EXISTS ... utf8mb4"]
|
|
185
|
-
```
|
|
69
|
+
<!-- bespoke diagram: edit diagrams/ddl-generation-flow.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
70
|
+

|
|
186
71
|
|
|
187
72
|
The `ID` and `ForeignKey` types designate the column as the primary key. The table is always created with `DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`.
|
|
188
73
|
|
|
@@ -194,15 +79,8 @@ The service includes guards against common connection issues:
|
|
|
194
79
|
|
|
195
80
|
### Double-Connect Prevention
|
|
196
81
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
A[connect called] --> B{Pool already exists?}
|
|
200
|
-
B -->|Yes| C[Log error with cleansed settings]
|
|
201
|
-
C --> D[Skip -- no new pool created]
|
|
202
|
-
B -->|No| E[Create mysql2 pool]
|
|
203
|
-
E --> F[Set connected = true]
|
|
204
|
-
F --> G[Log connection details]
|
|
205
|
-
```
|
|
82
|
+
<!-- bespoke diagram: edit diagrams/double-connect-prevention.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
83
|
+

|
|
206
84
|
|
|
207
85
|
If `connect()` is called when a pool already exists, the method logs an error with the connection settings (password masked as `*****************`) and returns without creating a second pool. This prevents connection leaks from accidental double-initialization.
|
|
208
86
|
|
|
@@ -220,26 +98,8 @@ The `connectAsync()` method wraps `connect()` in a try-catch:
|
|
|
220
98
|
|
|
221
99
|
When a Meadow entity sets its provider to `'MySQL'`, queries follow this path:
|
|
222
100
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
participant App as Application
|
|
226
|
-
participant Meadow as Meadow Entity
|
|
227
|
-
participant FH as FoxHound
|
|
228
|
-
participant Provider as Meadow-Provider-MySQL
|
|
229
|
-
participant MCS as MeadowConnectionMySQL
|
|
230
|
-
participant Pool as mysql2 Pool
|
|
231
|
-
|
|
232
|
-
App->>Meadow: doReads(query, callback)
|
|
233
|
-
Meadow->>FH: Build SQL query
|
|
234
|
-
FH-->>Meadow: SQL string + parameters
|
|
235
|
-
Meadow->>Provider: Execute read
|
|
236
|
-
Provider->>MCS: Get pool reference
|
|
237
|
-
MCS-->>Provider: mysql2 pool
|
|
238
|
-
Provider->>Pool: pool.query(sql, params)
|
|
239
|
-
Pool-->>Provider: Result rows
|
|
240
|
-
Provider-->>Meadow: Marshalled records
|
|
241
|
-
Meadow-->>App: callback(error, query, records)
|
|
242
|
-
```
|
|
101
|
+
<!-- bespoke diagram: edit diagrams/meadow-integration.mmd or .hints.json, then: npx pict-renderer-graph build modules/meadow/meadow-connection-mysql/docs -->
|
|
102
|
+

|
|
243
103
|
|
|
244
104
|
The connection pool is shared across all Meadow entities in the application. Each entity resolves the pool through the Fable service registry, so there is a single pool regardless of how many entity types are in use.
|
|
245
105
|
|