masterrecord 0.2.28 → 0.2.29
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/context.js +15 -1
- package/package.json +1 -1
package/context.js
CHANGED
|
@@ -38,7 +38,7 @@ class context {
|
|
|
38
38
|
SQLite expected model
|
|
39
39
|
{
|
|
40
40
|
"type": "better-sqlite3",
|
|
41
|
-
"connection" : "/db/",
|
|
41
|
+
"connection" : "/db/mydb.sqlite", // or "/db/" (auto-creates <contextname>.sqlite)
|
|
42
42
|
"password": "",
|
|
43
43
|
"username": ""
|
|
44
44
|
}
|
|
@@ -177,6 +177,13 @@ class context {
|
|
|
177
177
|
dbPath = path.join(file.rootFolder, trimmed);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
// If dbPath is a directory (ends with separator or exists as directory), append default filename
|
|
181
|
+
const endsWithSep = dbPath.endsWith('/') || dbPath.endsWith('\\');
|
|
182
|
+
const isDir = fs.existsSync(dbPath) && fs.statSync(dbPath).isDirectory();
|
|
183
|
+
if(endsWithSep || isDir){
|
|
184
|
+
const dbName = `${contextName.toLowerCase()}.sqlite`;
|
|
185
|
+
dbPath = path.join(dbPath, dbName);
|
|
186
|
+
}
|
|
180
187
|
const dbDir = path.dirname(dbPath);
|
|
181
188
|
if(!fs.existsSync(dbDir)){
|
|
182
189
|
fs.mkdirSync(dbDir, { recursive: true });
|
|
@@ -228,6 +235,13 @@ class context {
|
|
|
228
235
|
dbPath = path.join(file.rootFolder, trimmed);
|
|
229
236
|
}
|
|
230
237
|
}
|
|
238
|
+
// If dbPath is a directory (ends with separator or exists as directory), append default filename
|
|
239
|
+
const endsWithSep = dbPath.endsWith('/') || dbPath.endsWith('\\');
|
|
240
|
+
const isDir = fs.existsSync(dbPath) && fs.statSync(dbPath).isDirectory();
|
|
241
|
+
if(endsWithSep || isDir){
|
|
242
|
+
const dbName = `${contextName.toLowerCase()}.sqlite`;
|
|
243
|
+
dbPath = path.join(dbPath, dbName);
|
|
244
|
+
}
|
|
231
245
|
options.completeConnection = dbPath;
|
|
232
246
|
var dbDirectory = path.dirname(options.completeConnection);
|
|
233
247
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"app-root-path": "^3.1.0",
|
|
10
10
|
"better-sqlite3": "^12.4.1"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.29",
|
|
13
13
|
"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 ",
|
|
14
14
|
"homepage": "https://github.com/Tailor/MasterRecord#readme",
|
|
15
15
|
"repository": {
|