mevn-orm 2.3.3 → 2.3.5

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 (3) hide show
  1. package/initDb +10 -1
  2. package/lib/model.js +12 -2
  3. package/package.json +1 -1
package/initDb CHANGED
@@ -1,7 +1,16 @@
1
1
  #!/bin/env node
2
+ const fs = require('fs')
2
3
  require('dotenv').config()
3
4
  const Knex = require('knex')
4
- const { development, staging, production } = require('./knexfile.js')
5
+
6
+ let knexfilePath
7
+
8
+ if (fs.existsSync(process.cwd() + '/knexfile.js')) {
9
+ knexfilePath = process.cwd() + '/knexfile.js'
10
+ } else {
11
+ knexfilePath = process.cwd() + '/knexfile.cjs'
12
+ }
13
+ const { development, staging, production } = require(knexfilePath)
5
14
  let config
6
15
 
7
16
  switch (process.env.NODE_ENV) {
package/lib/model.js CHANGED
@@ -1,5 +1,15 @@
1
+ const fs = require('fs')
1
2
  const knex = require('knex').knex
2
- const { development, staging, production } = require(process.cwd() + '/knexfile.js')
3
+
4
+ let fileName
5
+
6
+ if (fs.existsSync(process.cwd() + '/knexfile.js')) {
7
+ fileName = process.cwd() + '/knexfile.js'
8
+ } else {
9
+ fileName = process.cwd() + '/knexfile.cjs'
10
+ }
11
+ const { development, staging, production } = require(fileName)
12
+
3
13
  const pluralize = require('pluralize')
4
14
  let config
5
15
  switch (process.env.NODE_ENV) {
@@ -178,7 +188,7 @@ class Model {
178
188
  foreignKey = `${this.modelName}_id`
179
189
  }
180
190
 
181
- if(localKey) {
191
+ if (localKey) {
182
192
  relation[foreignKey] = localKey
183
193
  const res = await DB(table).where(relation).first()
184
194
  if (res) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mevn-orm",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "simple ORM for express js",
5
5
  "type": "commonjs",
6
6
  "scripts": {