@wxn0brp/db 0.5.2 → 0.5.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/dist/relation.js CHANGED
@@ -1,4 +1,6 @@
1
1
  async function processRelations(dbs, cfg, data) {
2
+ if (!data)
3
+ return;
2
4
  for (const [key, relation] of Object.entries(cfg)) {
3
5
  const { pk = "_id", fk = "_id", type = "1" } = relation;
4
6
  if (type === "1") {
@@ -43,14 +45,14 @@ async function processRelations(dbs, cfg, data) {
43
45
  function selectDataSelf(data, select) {
44
46
  if (!data)
45
47
  return null;
46
- if (select.length === 0)
48
+ if (!select || select.length === 0)
47
49
  return data;
48
50
  if (Array.isArray(data))
49
51
  return data.map(item => selectDataSelf(item, select));
50
52
  return selectDataSelf(data[select[0]], select.slice(1));
51
53
  }
52
54
  function selectData(data, select) {
53
- if (select.length === 0)
55
+ if (!select || select.length === 0)
54
56
  return data;
55
57
  const newData = {};
56
58
  for (const field of select) {
@@ -1,10 +1,11 @@
1
+ import DataBaseRemote from "../client/database.js";
1
2
  import DataBase from "../database.js";
2
3
  import { DbFindOpts } from "./options.js";
3
4
  export declare namespace RelationTypes {
4
5
  type Path = [string, string];
5
6
  type FieldPath = string[];
6
7
  interface DBS {
7
- [key: string]: DataBase;
8
+ [key: string]: DataBase | DataBaseRemote;
8
9
  }
9
10
  interface Relation {
10
11
  [key: string]: RelationConfig;
package/package.json CHANGED
@@ -1,51 +1,45 @@
1
1
  {
2
- "name": "@wxn0brp/db",
3
- "version": "0.5.2",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "description": "A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.",
7
- "homepage": "https://github.com/wxn0brP/ValtheraDB",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/wxn0brP/ValtheraDB.git"
11
- },
12
- "keywords": [
13
- "database",
14
- "file-based",
15
- "CRUD",
16
- "graph",
17
- "query"
18
- ],
19
- "author": "wxn0brP",
20
- "license": "MIT",
21
- "type": "module",
22
- "dependencies": {
23
- "json5": "^2.2.3",
24
- "ky": "^1.7.4",
25
- "readline": "^1.3.0"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^22.10.2",
29
- "tsc-alias": "^1.8.10",
30
- "typescript": "^5.7.2"
31
- },
32
- "scripts": {
33
- "build": "tsc && tsc-alias",
34
- "prepare": "rm -rf dist && npm run build",
35
- "postversion": "git push && git push --tags",
36
- "build:cdn": "npm run build && cd cdn && node index.js"
37
- },
38
- "files": [
39
- "dist"
40
- ],
41
- "exports": {
42
- ".": {
43
- "types": "./dist/index.d.ts",
44
- "import": "./dist/index.js"
45
- },
46
- "./*": {
47
- "types": "./dist/*",
48
- "import": "./dist/*"
49
- }
50
- }
2
+ "name": "@wxn0brp/db",
3
+ "version": "0.5.3",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "description": "A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.",
7
+ "homepage": "https://github.com/wxn0brP/ValtheraDB",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/wxn0brP/ValtheraDB.git"
11
+ },
12
+ "keywords": [
13
+ "database",
14
+ "file-based",
15
+ "CRUD",
16
+ "graph",
17
+ "query"
18
+ ],
19
+ "author": "wxn0brP",
20
+ "license": "MIT",
21
+ "type": "module",
22
+ "dependencies": {
23
+ "json5": "^2.2.3",
24
+ "ky": "^1.7.4",
25
+ "readline": "^1.3.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.10.2",
29
+ "tsc-alias": "^1.8.10",
30
+ "typescript": "^5.7.2"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js"
39
+ },
40
+ "./*": {
41
+ "types": "./dist/*",
42
+ "import": "./dist/*"
43
+ }
44
+ }
51
45
  }