masterrecord 1.1.5 → 1.1.6

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/Tools.js CHANGED
@@ -19,9 +19,9 @@ class Tools{
19
19
  }
20
20
 
21
21
  static returnEntityList(list, entityList ){
22
- var newList = [];
23
- for(var max = 0; max < list.length; max++ ){
24
- var ent = entityList[list[max]];
22
+ const newList = [];
23
+ for(let max = 0; max < list.length; max++ ){
24
+ const ent = entityList[list[max]];
25
25
  if(ent){
26
26
  if(ent.relationshipType === "hasMany" || ent.relationshipType === "hasOne"){
27
27
  newList.push(ent.name);
@@ -38,15 +38,15 @@ class Tools{
38
38
  // this will remove everthing from back slash amount
39
39
  static removeBackwardSlashSection(string, amount, type){
40
40
  type = type === undefined ? "\\" : type;
41
- var stringArray = string.split(type);
42
- for(var i = 0; i < amount; i++){
41
+ const stringArray = string.split(type);
42
+ for(let i = 0; i < amount; i++){
43
43
  stringArray.pop();
44
44
  }
45
45
  return stringArray.join(type);
46
46
  }
47
47
 
48
48
  static getPrimaryKeyObject(model){
49
- for (var key in model) {
49
+ for (const key in model) {
50
50
  if (model.hasOwnProperty(key)) {
51
51
  if(model[key].primary){
52
52
  if(model[key].primary === true){
@@ -58,7 +58,7 @@ class Tools{
58
58
  }
59
59
 
60
60
  static findForeignTable(name, model){
61
- for (var key in model) {
61
+ for (const key in model) {
62
62
  if (model.hasOwnProperty(key)) {
63
63
  if(model[key].foreignTable){
64
64
  if(model[key].foreignTable === name){
@@ -85,7 +85,7 @@ class Tools{
85
85
 
86
86
  static clearAllProto(proto){
87
87
 
88
- var newproto = {}
88
+ const newproto = {}
89
89
  if(proto.__proto__ ){
90
90
  // Include non-enumerable own properties so we don't lose values defined via getters
91
91
  const keys = Object.getOwnPropertyNames(proto);
@@ -127,10 +127,10 @@ class Tools{
127
127
  }
128
128
 
129
129
  static removePrimarykeyandVirtual(currentModel, modelEntity){
130
- var newCurrentModel = Object.create(currentModel);
130
+ const newCurrentModel = Object.create(currentModel);
131
131
 
132
- for(var entity in modelEntity) {
133
- var currentEntity = modelEntity[entity];
132
+ for(const entity in modelEntity) {
133
+ const currentEntity = modelEntity[entity];
134
134
  if (modelEntity.hasOwnProperty(entity)) {
135
135
  if(currentEntity.primary === true){
136
136
  delete newCurrentModel[`_${entity}`];
@@ -146,8 +146,8 @@ class Tools{
146
146
  }
147
147
 
148
148
  static getEntity(name, modelEntity){
149
- for(var entity in modelEntity) {
150
- var currentEntity = modelEntity[entity];
149
+ for(const entity in modelEntity) {
150
+ const currentEntity = modelEntity[entity];
151
151
  if (modelEntity.hasOwnProperty(entity)) {
152
152
  if(currentEntity.__name === name){
153
153
  return currentEntity;
@@ -168,14 +168,14 @@ class Tools{
168
168
 
169
169
  // return randome letter that is not the skip letter
170
170
  static getRandomLetter(length, skip){
171
- var result = '';
172
- var characters = 'abcdefghijklmnopqrstuvwxyz';
173
- var charactersLength = characters.length;
171
+ let result = '';
172
+ const characters = 'abcdefghijklmnopqrstuvwxyz';
173
+ const charactersLength = characters.length;
174
174
 
175
- for ( var i = 0; i < length; i++ ) {
175
+ for ( let i = 0; i < length; i++ ) {
176
176
  result += characters.charAt(Math.floor(Math.random() * charactersLength));
177
177
  if(skip){
178
- for ( var b = 0; b < skip.length; b++ ) {
178
+ for ( let b = 0; b < skip.length; b++ ) {
179
179
  if(result === skip[i].entity){
180
180
  result = "";
181
181
  i--;
@@ -192,7 +192,7 @@ class Tools{
192
192
 
193
193
  static convertEntityToSelectParameterString(obj){
194
194
  // todo: loop throgh object and append string with comma to
195
- var mainString = "";
195
+ let mainString = "";
196
196
  const entries = Object.keys(obj);
197
197
  for (const key of entries) {
198
198
  // Skip lifecycle hooks - they are not database columns
package/context.js CHANGED
@@ -1069,7 +1069,7 @@ class context {
1069
1069
  }
1070
1070
 
1071
1071
  // Normalize type — require explicit type, no silent inference
1072
- let type = (options.type || '').toString().toLowerCase();
1072
+ const type = (options.type || '').toString().toLowerCase();
1073
1073
  if (!type) {
1074
1074
  throw new ConfigurationError(
1075
1075
  'Database type is required. Please specify type: "sqlite", "mysql", or "postgres" in your configuration.',
package/mySQLEngine.js CHANGED
@@ -472,7 +472,7 @@ class MySQLEngine {
472
472
  const includeQueries = [];
473
473
  const $that = this;
474
474
 
475
- for (let part in query.include) {
475
+ for (const part in query.include) {
476
476
  const includeEntity = query.include[part];
477
477
  if (includeEntity) {
478
478
  const parentObj = includeEntity[query.parentName];
@@ -537,7 +537,7 @@ class MySQLEngine {
537
537
  }
538
538
  }
539
539
  let func = expr.func;
540
- let arg = expr.arg;
540
+ const arg = expr.arg;
541
541
  if ((!func && typeof arg === 'undefined')) {
542
542
  return null;
543
543
  }
@@ -613,7 +613,7 @@ class MySQLEngine {
613
613
  }
614
614
 
615
615
  getEntity(name, maps) {
616
- for (let item in maps) {
616
+ for (const item in maps) {
617
617
  const map = maps[item];
618
618
  if (tools.capitalizeFirstLetter(name) === map.name) {
619
619
  return map.entity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "masterrecord",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
5
5
  "type": "module",
6
6
  "main": "./MasterRecord.js",
@@ -49,7 +49,9 @@
49
49
  "node": ">=20.0.0"
50
50
  },
51
51
  "scripts": {
52
- "test": "node --test test/ Migrations/pathUtils.test.js"
52
+ "test": "node --test test/ Migrations/pathUtils.test.js",
53
+ "lint": "eslint . --fix",
54
+ "lint:check": "eslint ."
53
55
  },
54
56
  "author": "Alexandr Rich",
55
57
  "license": "MIT",
@@ -76,5 +78,10 @@
76
78
  "mysql2": "^3.11.5",
77
79
  "app-root-path": "^3.1.0",
78
80
  "better-sqlite3": "^12.6.2"
81
+ },
82
+ "devDependencies": {
83
+ "@eslint/js": "^9.17.0",
84
+ "eslint": "^9.17.0",
85
+ "globals": "^15.14.0"
79
86
  }
80
87
  }
package/postgresEngine.js CHANGED
@@ -462,12 +462,12 @@ class postgresEngine {
462
462
  const entity = this.getEntity(query.parentName, query.entityMap);
463
463
  const andList = [];
464
464
 
465
- for (let entityPart in andEntity) {
465
+ for (const entityPart in andEntity) {
466
466
  const itemEntity = andEntity[entityPart];
467
- for (let table in itemEntity[query.parentName]) {
467
+ for (const table in itemEntity[query.parentName]) {
468
468
  const item = itemEntity[query.parentName][table];
469
469
  const expressions = [];
470
- for (let exp in item.expressions) {
470
+ for (const exp in item.expressions) {
471
471
  // Use the field name verbatim for SQL emission so it
472
472
  // matches the actual column case. The capitalized form
473
473
  // is only useful for the navigational-relationship
@@ -530,7 +530,7 @@ class postgresEngine {
530
530
  const item = whereEntity[query.parentName].query;
531
531
  const conditions = [];
532
532
 
533
- for (let exp in item.expressions) {
533
+ for (const exp in item.expressions) {
534
534
  // Use the field name verbatim for SQL emission. See buildAnd for full rationale.
535
535
  const originalField = item.expressions[exp].field;
536
536
  const capitalized = tools.capitalizeFirstLetter(originalField);
@@ -643,7 +643,7 @@ class postgresEngine {
643
643
  const dirtyFields = model.__dirtyFields;
644
644
  let paramIndex = 1;
645
645
 
646
- for (let column in dirtyFields) {
646
+ for (const column in dirtyFields) {
647
647
  const fieldName = dirtyFields[column];
648
648
  const entityDef = model.__entity[fieldName];
649
649
 
@@ -795,7 +795,7 @@ class postgresEngine {
795
795
  const $that = this;
796
796
  const columnNames = [];
797
797
  const params = [];
798
- let paramIndex = 1;
798
+ const paramIndex = 1;
799
799
 
800
800
  for (const column in modelEntity) {
801
801
  if (column.indexOf("__") === -1) {