murmuration 1.1.1 → 1.1.3

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.
Files changed (2) hide show
  1. package/bin/statement.js +14 -1
  2. package/package.json +1 -1
package/bin/statement.js CHANGED
@@ -2,9 +2,12 @@
2
2
 
3
3
  const { arrayUtilities } = require("necessary");
4
4
 
5
+ const database = require("./database");
6
+
5
7
  const { EMPTY_STRING } = require("./constants");
6
8
 
7
- const { first } = arrayUtilities;
9
+ const { first } = arrayUtilities,
10
+ { query, execute: command } = database;
8
11
 
9
12
  class Statement {
10
13
  constructor(connection, sql, query, parameters, oneHandler, noneHandler, manyHandler, elseHandler, firstHandler, errorHandler, successHandler) {
@@ -69,6 +72,10 @@ class Statement {
69
72
  this.sql = sql;
70
73
  }
71
74
 
75
+ setQuery(query) {
76
+ this.query = query;
77
+ }
78
+
72
79
  one(oneHandler) {
73
80
  this.oneHandler = oneHandler;
74
81
 
@@ -253,6 +260,12 @@ class Statement {
253
260
  return clause;
254
261
  }
255
262
 
263
+ execute() {
264
+ this.query ?
265
+ query(this.connection, this.sql, ...this.parameters, this.queryHandler) :
266
+ command(this.connection, this.sql, ...this.parameters, this.commandHandler);
267
+ }
268
+
256
269
  queryHandler = (error, rows) => {
257
270
  if (error) {
258
271
  this.errorHandler(error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "murmuration",
3
3
  "author": "James Smith",
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/murmuration",
7
7
  "description": "Database connections, transactions and migrations.",