milodb 1.0.1 → 1.0.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.
- package/package.json +1 -1
- package/src/cli.js +3 -8
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -2,25 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs-extra');
|
|
5
|
-
const MiloDB = require('
|
|
5
|
+
const MiloDB = require(path.join(__dirname, 'milodb')); // Use path.join to correctly reference the file
|
|
6
6
|
|
|
7
7
|
// Function to initialize the database
|
|
8
8
|
async function initDatabase() {
|
|
9
|
-
const dbPath = path.join(process.cwd(), '
|
|
9
|
+
const dbPath = path.join(process.cwd(), 'db'); // Set the path where the database will be stored in the host project
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
// Create a new instance of MiloDB
|
|
13
13
|
const db = new MiloDB(dbPath, false); // Default to no encryption
|
|
14
14
|
|
|
15
15
|
// Ensure the database folder exists
|
|
16
|
-
fs.
|
|
16
|
+
await fs.ensureDir(dbPath);
|
|
17
17
|
|
|
18
18
|
console.log(`Database initialized at: ${dbPath}`);
|
|
19
|
-
|
|
20
|
-
// Optionally, you could create a default table
|
|
21
|
-
// await db.createTable('users');
|
|
22
|
-
// console.log('Default "users" table created.');
|
|
23
|
-
|
|
24
19
|
} catch (error) {
|
|
25
20
|
console.error('Error initializing database:', error.message);
|
|
26
21
|
process.exit(1);
|