@cocreate/mysql 1.0.0 → 1.2.0
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/CHANGELOG.md +14 -0
- package/README.md +141 -51
- package/package.json +14 -10
- package/src/index.js +27 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/CoCreate-app/CoCreate-mysql/compare/v1.1.0...v1.2.0) (2026-07-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update README.md to reflect MySQL integration and enhance documentation ([e2546cb](https://github.com/CoCreate-app/CoCreate-mysql/commit/e2546cb459dd85d71f76e1d7335d2c8a8bea1ce1))
|
|
7
|
+
|
|
8
|
+
# [1.1.0](https://github.com/CoCreate-app/CoCreate-mysql/compare/v1.0.0...v1.1.0) (2026-07-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* update package.json description and keywords; migrate to ES modules in index.js ([1d6710a](https://github.com/CoCreate-app/CoCreate-mysql/commit/1d6710a5c0f0251762d3560eef9b1a49021e12ba))
|
|
14
|
+
|
|
1
15
|
# 1.0.0 (2026-07-18)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,88 +1,178 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mysql
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A highly efficient, enterprise-grade MySQL relational database CRUD wrapper and state-routing backend client for the collaborative CoCreate ecosystem. This wrapper maps MySQL's robust, world-standard structured SQL capabilities into CoCreate's unified JSON interface.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-

|
|
5
|
+
## Documentation
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
For a complete guide and working integration examples, refer to the [CoCreate MySQL Documentation](https://www.google.com/search?q=https://cocreatejs.com/docs/mysql).
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
---
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## Table of Contents
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
* [The Power of the CoCreate Unified Ecosystem](https://www.google.com/search?q=%23the-power-of-the-cocreate-unified-ecosystem)
|
|
14
|
+
* [Why MySQL?](https://www.google.com/search?q=%23why-mysql)
|
|
15
|
+
* [Installation](https://www.google.com/search?q=%23installation)
|
|
16
|
+
* [Unified JSON Payload Examples](https://www.google.com/search?q=%23unified-json-payload-examples)
|
|
17
|
+
* [Announcements](https://www.google.com/search?q=%23announcements)
|
|
18
|
+
* [Roadmap](https://www.google.com/search?q=%23roadmap)
|
|
19
|
+
* [How to Contribute](https://www.google.com/search?q=%23how-to-contribute)
|
|
20
|
+
* [About](https://www.google.com/search?q=%23about)
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.js"></script>
|
|
19
|
-
```
|
|
22
|
+
---
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.css"></script>
|
|
23
|
-
```
|
|
24
|
+
## The Power of the CoCreate Unified Ecosystem
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
This is not just another database driver. By wrapping MySQL into the CoCreate state-routing pipeline, you unlock the full power of a multi-cloud, multi-model data orchestration mesh:
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
* **Unified JSON Interface (MongoDB-like Syntax):** You don't need to write custom SQL strings or manually manage relational column mappings. CoCreate translates standard NoSQL JSON CRUD operations (such as `object.create` or `object.read`) transparently into optimized MySQL transactional SQL under the hood.
|
|
29
|
+
* **Parallel Multi-Database Writing:** Write to many target databases simultaneously with a single API call. You can stream transactional data to MongoDB (for instant operational state), vectorize it into Qdrant (for real-time semantic search), and persist it in MySQL (for enterprise-grade relational warehousing) in perfect parallel harmony:
|
|
30
|
+
|
|
31
|
+
$$\text{Write Command} \xrightarrow{\text{Parallel Mesh}} \begin{cases} \text{MongoDB} & \text{(ACID Transaction Store)} \\ \text{Qdrant} & \text{(Semantic Vector Search)} \\ \text{MySQL} & \text{(Enterprise Relational Core)} \end{cases}$$
|
|
32
|
+
|
|
33
|
+
* **Dynamic State-Routing:** Isolate multi-tenant environments effortlessly. The routing mesh automatically injects tenant metadata and organization boundaries, ensuring isolated database processing within your shared MySQL infrastructure.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Why MySQL?
|
|
38
|
+
|
|
39
|
+
MySQL is the world's most popular open-source relational database management system. It serves as the primary relational backbone for many of the world's largest digital enterprises. It offers robust transaction support (via InnoDB), enterprise-grade replication options, high availability setups, and strict data integrity compliance.
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
By routing operational states, structured analytical reporting datasets, and secure transactional tables to MySQL via this wrapper, you unlock standard, fault-tolerant SQL reliability directly within your unified infrastructure.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
### NPM Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm i @cocreate/mysql
|
|
32
51
|
|
|
33
|
-
```shell
|
|
34
|
-
$ yarn install @cocreate/mongodb
|
|
35
52
|
```
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
### Yarn Installation
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- [Roadmap](#roadmap)
|
|
42
|
-
- [How to Contribute](#how-to-contribute)
|
|
43
|
-
- [About](#about)
|
|
44
|
-
- [License](#license)
|
|
56
|
+
```bash
|
|
57
|
+
yarn add @cocreate/mysql
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
```
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Unified JSON Payload Examples
|
|
64
|
+
|
|
65
|
+
Here are the complete, real-world JSON objects representing raw payloads routed through the CoCreate system. By declaring an array in the `storage` key, CoCreate fires the write operations to all specified backends simultaneously in parallel.
|
|
66
|
+
|
|
67
|
+
### 1. Writing a Full Transaction Object (`object.create`)
|
|
68
|
+
|
|
69
|
+
When this operational payload is sent, CoCreate registers it, processes the nested JSON fields, and automatically warehouses it across all listed parallel storage platforms.
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"method": "object.create",
|
|
74
|
+
"storage": ["mysql", "mongodb", "qdrant"], // Array of storages to store in parallel!
|
|
75
|
+
"database": "sales_analytics",
|
|
76
|
+
"array": "order_events",
|
|
77
|
+
"object": {
|
|
78
|
+
"_id": "order_77c8f2a9_3b01",
|
|
79
|
+
"customer": {
|
|
80
|
+
"id": "cust_88301",
|
|
81
|
+
"email": "customer@example.com",
|
|
82
|
+
"region": "North America",
|
|
83
|
+
"acquisition_channel": "Google Search"
|
|
84
|
+
},
|
|
85
|
+
"transaction": {
|
|
86
|
+
"payment_method": "Credit Card",
|
|
87
|
+
"currency": "USD",
|
|
88
|
+
"subtotal": 249.99,
|
|
89
|
+
"discount": 15.00,
|
|
90
|
+
"tax": 18.80,
|
|
91
|
+
"total": 253.79
|
|
92
|
+
},
|
|
93
|
+
"items": [
|
|
94
|
+
{
|
|
95
|
+
"product_id": "prod_head_009",
|
|
96
|
+
"name": "Wireless Noise-Cancelling Headphones",
|
|
97
|
+
"category": "Electronics",
|
|
98
|
+
"quantity": 1,
|
|
99
|
+
"unit_price": 199.99
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"product_id": "prod_stand_012",
|
|
103
|
+
"name": "Aluminum Headphone Stand",
|
|
104
|
+
"category": "Accessories",
|
|
105
|
+
"quantity": 2,
|
|
106
|
+
"unit_price": 25.00
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"shipping": {
|
|
110
|
+
"carrier": "FedEx",
|
|
111
|
+
"service": "2-Day Air",
|
|
112
|
+
"estimated_delivery": "2026-07-20T12:00:00.000Z"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"organization_id": "org_enterprise_99x",
|
|
116
|
+
"user_id": "usr_sales_runner_402",
|
|
117
|
+
"timeStamp": "2026-07-18T18:40:43.000Z"
|
|
118
|
+
}
|
|
49
119
|
|
|
50
|
-
|
|
120
|
+
```
|
|
51
121
|
|
|
52
|
-
|
|
122
|
+
### 2. Reading and Filtering Warehoused Data (`object.read`)
|
|
123
|
+
|
|
124
|
+
Querying targets a single database engine via a string filter syntax. The query below retrieves high-value orders handled by a specific shipping carrier from MySQL, sorting them by total sale volume.
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"method": "object.read",
|
|
129
|
+
"storage": "mysql",
|
|
130
|
+
"database": "sales_analytics",
|
|
131
|
+
"array": "order_events",
|
|
132
|
+
"$filter": {
|
|
133
|
+
"query": {
|
|
134
|
+
"transaction.total": { "$gte": 100.00 },
|
|
135
|
+
"shipping.carrier": "FedEx"
|
|
136
|
+
},
|
|
137
|
+
"sort": [
|
|
138
|
+
{ "key": "transaction.total", "direction": "desc" }
|
|
139
|
+
],
|
|
140
|
+
"limit": 50,
|
|
141
|
+
"index": 0
|
|
142
|
+
},
|
|
143
|
+
"organization_id": "org_enterprise_99x"
|
|
144
|
+
}
|
|
53
145
|
|
|
54
|
-
|
|
146
|
+
```
|
|
55
147
|
|
|
56
|
-
|
|
148
|
+
---
|
|
57
149
|
|
|
58
|
-
|
|
150
|
+
## Announcements
|
|
59
151
|
|
|
60
|
-
|
|
152
|
+
All updates to this library are documented in our `CHANGELOG` and releases. You may also subscribe to email for releases and breaking changes.
|
|
61
153
|
|
|
62
|
-
|
|
154
|
+
---
|
|
63
155
|
|
|
64
|
-
|
|
156
|
+
## Roadmap
|
|
65
157
|
|
|
66
|
-
|
|
158
|
+
If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.
|
|
67
159
|
|
|
68
|
-
|
|
160
|
+
---
|
|
69
161
|
|
|
70
|
-
|
|
162
|
+
## How to Contribute
|
|
71
163
|
|
|
72
|
-
We encourage contribution to our libraries (you might even score some nifty swag), please see our
|
|
164
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our `CONTRIBUTING` guide for details.
|
|
73
165
|
|
|
74
|
-
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create
|
|
166
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or merely upvote or comment on existing issues or pull requests.
|
|
75
167
|
|
|
76
168
|
We appreciate your continued support, thank you!
|
|
77
169
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# License
|
|
170
|
+
---
|
|
81
171
|
|
|
82
|
-
|
|
172
|
+
## About
|
|
83
173
|
|
|
84
|
-
-
|
|
174
|
+
`CoCreate-mysql` is guided and supported by the **CoCreate Developer Experience Team**.
|
|
85
175
|
|
|
86
|
-
|
|
176
|
+
> Please Email the Developer Experience Team here in case of any queries.
|
|
87
177
|
|
|
88
|
-
|
|
178
|
+
`CoCreate-mysql` is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/mysql",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Lightweight MySQL, MariaDB, and Aurora CRUD wrapper and multi-tenant state routing client for the CoCreate ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mysql",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
7
|
+
"mariadb",
|
|
8
|
+
"aurora",
|
|
9
|
+
"sql",
|
|
10
|
+
"json",
|
|
11
|
+
"crud-api",
|
|
12
|
+
"abstract-crud",
|
|
13
|
+
"database-abstraction",
|
|
14
|
+
"multi-tenant",
|
|
15
|
+
"multi-tenant-routing",
|
|
16
|
+
"realtime-sync",
|
|
17
|
+
"state-synchronization"
|
|
14
18
|
],
|
|
15
19
|
"publishConfig": {
|
|
16
20
|
"access": "public"
|
|
@@ -38,6 +42,6 @@
|
|
|
38
42
|
"main": "./src/index.js",
|
|
39
43
|
"dependencies": {
|
|
40
44
|
"@cocreate/utils": "^1.44.0",
|
|
41
|
-
"
|
|
45
|
+
"mysql2": "^3.22.6"
|
|
42
46
|
}
|
|
43
47
|
}
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2026 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
|
|
18
|
+
import mysql from "mysql2/promise";
|
|
19
|
+
import {
|
|
3
20
|
dotNotationToObject,
|
|
4
21
|
queryData,
|
|
5
22
|
searchData,
|
|
6
23
|
sortData,
|
|
7
24
|
isValidDate
|
|
8
|
-
}
|
|
25
|
+
} from "@cocreate/utils";
|
|
9
26
|
|
|
10
27
|
const organizations = {};
|
|
11
28
|
|
|
@@ -91,7 +108,7 @@ process.on("orgDeleted", (organization_id) => {
|
|
|
91
108
|
/**
|
|
92
109
|
* Universal router routing request methods safely.
|
|
93
110
|
*/
|
|
94
|
-
function send(data) {
|
|
111
|
+
export function send(data) {
|
|
95
112
|
let [type, method] = data.method.split(".");
|
|
96
113
|
if (type === "database") return database(method, data);
|
|
97
114
|
if (type === "array") return array(method, data);
|
|
@@ -109,7 +126,7 @@ function database(method, data) {
|
|
|
109
126
|
|
|
110
127
|
try {
|
|
111
128
|
const pool = await dbClient(data);
|
|
112
|
-
if (!pool || pool.status === false) return data;
|
|
129
|
+
if (!pool || pool.status === false) return resolve(data);
|
|
113
130
|
|
|
114
131
|
if (method === "read") {
|
|
115
132
|
const sql = "SHOW DATABASES;";
|
|
@@ -171,9 +188,6 @@ function database(method, data) {
|
|
|
171
188
|
console.log(method, "error", error);
|
|
172
189
|
resolve(data);
|
|
173
190
|
}
|
|
174
|
-
},
|
|
175
|
-
(error) => {
|
|
176
|
-
errorHandler(data, error);
|
|
177
191
|
}
|
|
178
192
|
);
|
|
179
193
|
}
|
|
@@ -189,7 +203,7 @@ function array(method, data) {
|
|
|
189
203
|
|
|
190
204
|
try {
|
|
191
205
|
const pool = await dbClient(data);
|
|
192
|
-
if (!pool || pool.status === false) return data;
|
|
206
|
+
if (!pool || pool.status === false) return resolve(data);
|
|
193
207
|
|
|
194
208
|
if (data.request) data.array = data.request;
|
|
195
209
|
|
|
@@ -334,9 +348,6 @@ function array(method, data) {
|
|
|
334
348
|
console.log(method, "error", error);
|
|
335
349
|
resolve(data);
|
|
336
350
|
}
|
|
337
|
-
},
|
|
338
|
-
(error) => {
|
|
339
|
-
errorHandler(data, error);
|
|
340
351
|
}
|
|
341
352
|
);
|
|
342
353
|
}
|
|
@@ -349,7 +360,7 @@ function object(method, data) {
|
|
|
349
360
|
async (resolve, reject) => {
|
|
350
361
|
try {
|
|
351
362
|
const pool = await dbClient(data);
|
|
352
|
-
if (!pool || pool.status === false) return data;
|
|
363
|
+
if (!pool || pool.status === false) return resolve(data);
|
|
353
364
|
|
|
354
365
|
let type = "object";
|
|
355
366
|
let documents = [];
|
|
@@ -584,9 +595,6 @@ function object(method, data) {
|
|
|
584
595
|
console.log(method, "error", error);
|
|
585
596
|
resolve(data);
|
|
586
597
|
}
|
|
587
|
-
},
|
|
588
|
-
(error) => {
|
|
589
|
-
errorHandler(data, error);
|
|
590
598
|
}
|
|
591
599
|
);
|
|
592
600
|
}
|
|
@@ -654,7 +662,8 @@ async function executeUpdateTransaction(pool, arrayName, docId, rawUpdateInput,
|
|
|
654
662
|
}
|
|
655
663
|
|
|
656
664
|
/**
|
|
657
|
-
* Applies MongoDB update operators
|
|
665
|
+
* Applies MongoDB update operators ($set, $unset, $push, $pull, $addToSet, $inc)
|
|
666
|
+
* recursively on a target record to maintain unified schema manipulation behaviors.
|
|
658
667
|
*/
|
|
659
668
|
function applyMongoUpdate(record, updatePayload) {
|
|
660
669
|
let target = { ...record };
|
|
@@ -907,4 +916,4 @@ function errorHandler(data, error, database, array) {
|
|
|
907
916
|
}
|
|
908
917
|
}
|
|
909
918
|
|
|
910
|
-
|
|
919
|
+
export default { send };
|