murmuration-mariadb 1.0.47 → 2.0.1

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.
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ const Statement = require("./statement");
4
+
5
+ function using(connection) {
6
+ const statement = Statement.fromConnection(connection);
7
+
8
+ return statement;
9
+ }
10
+
11
+ module.exports = using;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ const { Statement: BaseStatement, caseUtilities } = require("murmuration");
4
+
5
+ const { camelCaseToSnakeCase, snakeCaseToCamelCase } = caseUtilities;
6
+
7
+ class Statement extends BaseStatement {
8
+ update(relation) {
9
+ const sql = `UPDATE \`${relation}\``;
10
+
11
+ this.setSQL(sql);
12
+
13
+ return this;
14
+ }
15
+
16
+ insertInto(relation) {
17
+ const sql = `INSERT INTO \`${relation}\``;
18
+
19
+ this.setSQL(sql);
20
+
21
+ return this;
22
+ }
23
+
24
+ deleteFrom(relation) {
25
+ const sql = `DELETE FROM \`${relation}\``;
26
+
27
+ this.setSQL(sql);
28
+
29
+ return this;
30
+ }
31
+
32
+ selectFrom(relation) {
33
+ const sql = `SELECT * FROM \`${relation}\``,
34
+ query = true;
35
+
36
+ this.setSQL(sql);
37
+
38
+ this.setQuery(query);
39
+
40
+ return this;
41
+ }
42
+
43
+ placeholder() {
44
+ const placeholder = "?";
45
+
46
+ return placeholder;
47
+ }
48
+
49
+ columnFromKey(key) {
50
+ const column = `\`${camelCaseToSnakeCase(key)}\``;
51
+
52
+ return column;
53
+ }
54
+
55
+ keyFromColumn(column) {
56
+ const key = snakeCaseToCamelCase(column);
57
+
58
+ return key;
59
+ }
60
+
61
+ static fromConnection(Class, connection) {
62
+ if (connection === undefined) {
63
+ connection = Class; ///
64
+
65
+ Class = Statement;
66
+ }
67
+
68
+ const sql = null,
69
+ query = false,
70
+ parameters = [],
71
+ oneHandler = null,
72
+ noneHandler = null,
73
+ manyHandler = null,
74
+ elseHandler = null,
75
+ firstHandler = null,
76
+ errorHandler = null,
77
+ successHandler = null,
78
+ statement = new Class(connection, sql, query, parameters, oneHandler, noneHandler, manyHandler, elseHandler, firstHandler, errorHandler, successHandler);
79
+
80
+ return statement;
81
+ }
82
+ }
83
+
84
+ module.exports = Statement;
package/index.js CHANGED
@@ -2,15 +2,19 @@
2
2
 
3
3
  const murmuration = require("murmuration");
4
4
 
5
- const migrate = require("./bin/migrate"),
6
- Connection = require("./bin/connection"),
7
- transaction = require("./bin/transaction");
5
+ const using = require("./bin/using"),
6
+ migrate = require("./bin/migrate"),
7
+ Statement = require("./bin/statement"),
8
+ Connection = require("./bin/connection"),
9
+ transaction = require("./bin/transaction");
8
10
 
9
11
  const { database, CustomMigration } = murmuration;
10
12
 
11
13
  module.exports = {
12
14
  database,
15
+ using,
13
16
  migrate,
17
+ Statement,
14
18
  Connection,
15
19
  transaction,
16
20
  CustomMigration
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "murmuration-mariadb",
3
3
  "author": "James Smith",
4
- "version": "1.0.47",
4
+ "version": "2.0.1",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/murmuration-mariadb",
7
7
  "description": "Statements, transactions and migrations for MariaDB.",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/djalbat/murmuration-mariadb"
11
11
  },
12
12
  "dependencies": {
13
- "murmuration": "^1.1.13",
13
+ "murmuration": "^2.0.1",
14
14
  "mysql": "^2.18.1"
15
15
  },
16
16
  "devDependencies": {},