@wxn0brp/db 0.40.0 → 0.40.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # <img src="https://raw.githubusercontent.com/wxn0brP/ValtheraDB/main/logo.svg" alt="ValtheraDB Logo" width="36" height="36"> ValtheraDB (@wxn0brp/db)
1
+ # <img src="https://raw.githubusercontent.com/wxn0brP/ValtheraDB/master/logo.svg" alt="ValtheraDB Logo" width="36" height="36"> ValtheraDB (@wxn0brp/db)
2
2
 
3
- A lightweight file-based database management system that supports CRUD operations, custom queries, and graph structures.
3
+ A lightweight file-based database management system that supports CRUD operations, custom queries and relations.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@wxn0brp/db)](https://www.npmjs.com/package/@wxn0brp/db)
6
6
  [![License](https://img.shields.io/npm/l/@wxn0brp/db)](./LICENSE)
@@ -16,37 +16,37 @@ npm install @wxn0brp/db
16
16
 
17
17
  ## Usage
18
18
 
19
- You can import the necessary classes from the package as follows:
19
+ You can import the necessary classes/functions from the package as follows:
20
20
 
21
21
  ```javascript
22
- import { Valthera, Graph, ValtheraRemote, GraphRemote, Relation, genId, ValtheraMemory, ValtheraAutoCreate } from "@wxn0brp/db";
22
+ import { Valthera, ValtheraRemote, Relation, genId, ValtheraMemory, ValtheraAutoCreate } from "@wxn0brp/db";
23
23
  ```
24
24
 
25
25
  ### Examples
26
26
  ```javascript
27
- import { Valthera } from '@wxn0brp/db';
27
+ import { Valthera } from "@wxn0brp/db";
28
28
 
29
29
  // Create a new Valthera database instance
30
- const db = new Valthera('./database');
30
+ const db = new Valthera("./database");
31
31
 
32
32
  // Add a new document to the database
33
- const result = await db.add('users', { name: 'John Doe', age: 30 });
34
- console.log(result); // { _id: 'xxx', name: 'John Doe', age: 30 }
33
+ const addResult = await db.add("users", { name: "John Doe", age: 30 });
34
+ console.log(addResult); // { _id: "abcdefghi-4-9", name: "John Doe", age: 30 }
35
35
 
36
36
  // Find all documents in the collection
37
- const results = await db.find('users', {});
38
- console.log(results); // [{ _id: 'xxx', name: 'John Doe', age: 30 }]
37
+ const findResults = await db.find("users", {});
38
+ console.log(findResults); // [{ _id: "abcdefghi-4-9", name: "John Doe", age: 30 }]
39
39
 
40
40
  // Find a single document in the collection.
41
- const user = await db.findOne('users', { $gt: { age: 25 } });
42
- console.log(user); // { _id: 'xxx', name: 'John Doe', age: 30 }
41
+ const user = await db.findOne("users", { $gt: { age: 25 } });
42
+ console.log(user); // { _id: "abcdefghi-4-9", name: "John Doe", age: 30 }
43
43
 
44
44
  // Update a document in the collection
45
- const updateResult = await db.updateOne('users', { name: 'John Doe' }, { age: 31 });
45
+ const updateResult = await db.updateOne("users", { name: "John Doe" }, { age: 31 });
46
46
  console.log(updateResult); // true
47
47
 
48
48
  // Remove a document from the collection
49
- const removeResult = await db.removeOne('users', { name: 'John Doe' });
49
+ const removeResult = await db.removeOne("users", { name: "John Doe" });
50
50
  console.log(removeResult); // true
51
51
  ```
52
52
 
@@ -57,12 +57,12 @@ Website: [https://wxn0brp.github.io/ValtheraDB/](https://wxn0brp.github.io/Valth
57
57
  For detailed information, refer to the following resources:
58
58
 
59
59
  - [Valthera Documentation](./docs/valthera.md)
60
- - [Graph Documentation](./docs/graph.md)
61
60
  - [Remote Valthera and Graph Client Documentation](./docs/remote.md)
62
61
  - [Search Options Documentation](./docs/search_opts.md)
63
62
  - [Find Options Documentation](./docs/find_opts.md)
64
63
  - [Updater Options Documentation](./docs/updater.md)
65
64
  - [Relation Documentation](./docs/relation.md)
65
+ - [Graph Documentation](./docs/graph.md)
66
66
 
67
67
  ## License
68
68
 
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import Valthera from "./valthera.js";
3
+ const args = process.argv.slice(2);
4
+ if (args.length < 2) {
5
+ console.error(`Use: ${process.argv[1]} <path> <op> <collection> [args]`);
6
+ process.exit(1);
7
+ }
8
+ const path = args.shift();
9
+ const op = args.shift();
10
+ const opts = args.map((arg) => {
11
+ try {
12
+ return JSON.parse(arg);
13
+ }
14
+ catch {
15
+ return arg;
16
+ }
17
+ });
18
+ const db = new Valthera(path);
19
+ try {
20
+ const res = await db[op](...opts);
21
+ console.log(JSON.stringify(res));
22
+ }
23
+ catch (e) {
24
+ console.error(e);
25
+ process.exit(1);
26
+ }
package/dist/graph.d.ts CHANGED
@@ -3,6 +3,7 @@ import Valthera from "./valthera.js";
3
3
  /**
4
4
  * A class representing a graph database.
5
5
  * @class
6
+ * @deprecated
6
7
  */
7
8
  declare class Graph {
8
9
  db: Valthera;
package/dist/graph.js CHANGED
@@ -2,6 +2,7 @@ import Valthera from "./valthera.js";
2
2
  /**
3
3
  * A class representing a graph database.
4
4
  * @class
5
+ * @deprecated
5
6
  */
6
7
  class Graph {
7
8
  db;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import GraphRemote from "@wxn0brp/db-client/graph";
2
2
  import { ValtheraAutoCreate } from "./autoCreate.js";
3
3
  import Graph from "./graph.js";
4
4
  import { Valthera } from "./valthera.js";
5
+ /** @deprecated */
5
6
  type GraphCompatible = Graph | GraphRemote;
6
7
  export * from "@wxn0brp/db-core";
7
8
  export * from "@wxn0brp/db-client";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.40.0";
1
+ export const version = "0.40.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db",
3
- "version": "0.40.0",
3
+ "version": "0.40.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
@@ -11,10 +11,22 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/wxn0brP/ValtheraDB.git"
13
13
  },
14
+ "bin": {
15
+ "valthera-db-cli": "./dist/bin.js"
16
+ },
17
+ "keywords": [
18
+ "valthera",
19
+ "db",
20
+ "database",
21
+ "file",
22
+ "storage",
23
+ "data",
24
+ "lightweight"
25
+ ],
14
26
  "dependencies": {
15
- "@wxn0brp/db-client": ">=0.2.0",
16
- "@wxn0brp/db-core": ">=0.2.0",
17
- "@wxn0brp/db-storage-dir": ">=0.1.1"
27
+ "@wxn0brp/db-client": ">=0.2.1",
28
+ "@wxn0brp/db-core": ">=0.2.5",
29
+ "@wxn0brp/db-storage-dir": ">=0.1.4"
18
30
  },
19
31
  "devDependencies": {
20
32
  "@types/node": "*",