groupcore-utils 3.0.3 → 3.0.4

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/database/crud.js +3 -8
  2. package/package.json +1 -1
package/database/crud.js CHANGED
@@ -109,21 +109,16 @@ module.exports = class {
109
109
  let updateQuery = '';
110
110
 
111
111
  // set this to be used inside the map function to check when we get to the last index key so that we dont add the comma to the last key in the generated sql query
112
- const count = Object.keys(data).length - 1; // adding -1 because we are taking out 'id' in the filter method
113
112
  Object.keys(data)
114
113
  .filter((key) => key !== 'id')
115
- .forEach((key, i) => {
116
- if (count - i === 1) {
117
- updateQuery += `${key} = '${escapeQuotes(data[key])}'`;
118
- } else {
119
- updateQuery += `${key} = '${escapeQuotes(data[key])}', `;
120
- }
114
+ .forEach((key) => {
115
+ updateQuery += `${key} = '${escapeQuotes(data[key])}', `;
121
116
  return true;
122
117
  });
123
118
 
124
119
  const query = `update ${this.dbTable} set ${updateQuery} where id = '${id}'`;
125
120
 
126
- return this.db.query(query);
121
+ return this.db.query(query.replace(', where', ' where')); // using replace to remove the last comma before the where clause
127
122
  }
128
123
 
129
124
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groupcore-utils",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Utilities for working with some core features",
5
5
  "main": "Utils.js",
6
6
  "scripts": {