@quatrain/backend-sqlite 1.1.7 → 1.1.8

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.
@@ -10,7 +10,6 @@ export declare class SQLiteAdapter extends AbstractBackendAdapter {
10
10
  protected _connection: undefined | Database<sqlite3.Database>;
11
11
  protected _dbPath: string;
12
12
  constructor(params?: BackendParameters);
13
- protected _buildPath(dataObject: DataObjectClass<any>, uid?: string): string;
14
13
  /**
15
14
  * Executes an arbitrary raw SQL query against the SQLite database.
16
15
  *
@@ -26,7 +25,7 @@ export declare class SQLiteAdapter extends AbstractBackendAdapter {
26
25
  * @param filterNulls
27
26
  * @returns
28
27
  */
29
- protected _prepareData(data: any, filterNulls?: boolean): any;
28
+ protected _prepareData(data: any, filterNulls?: boolean): any[];
30
29
  /**
31
30
  * Ensure the collection table exists in SQLite
32
31
  * @param dataObject DataObject to create table for
@@ -44,24 +44,6 @@ class SQLiteAdapter extends backend_1.AbstractBackendAdapter {
44
44
  super(params);
45
45
  this._dbPath = ((_a = params.config) === null || _a === void 0 ? void 0 : _a.database) || ':memory:';
46
46
  }
47
- _buildPath(dataObject, uid) {
48
- const collection = this.getCollection(dataObject);
49
- if (!collection) {
50
- throw new backend_1.BackendError(`[SQLA] Can't define record path without a collection name`);
51
- }
52
- // define document path
53
- let path = `${collection}/${uid}`;
54
- if (this._params.hierarchy &&
55
- this._params.hierarchy[collection] ===
56
- backend_1.CollectionHierarchy.SUBCOLLECTION &&
57
- dataObject.parentProp &&
58
- dataObject.has(dataObject.parentProp) &&
59
- dataObject.val(dataObject.parentProp)) {
60
- path = `${dataObject.val(dataObject.parentProp).path}/${path}`;
61
- }
62
- backend_1.Backend.info(`[SQLA] Record path is '${path}'`);
63
- return path;
64
- }
65
47
  /**
66
48
  * Executes an arbitrary raw SQL query against the SQLite database.
67
49
  *
@@ -119,21 +101,7 @@ class SQLiteAdapter extends backend_1.AbstractBackendAdapter {
119
101
  data[key] = JSON.stringify(el);
120
102
  }
121
103
  });
122
- if (this._params['useNativeForeignKeys'] &&
123
- this._params['useNativeForeignKeys'] === true) {
124
- data.forEach((el, key) => {
125
- if (typeof el === 'object' &&
126
- el !== null &&
127
- Reflect.has(el, 'ref')) {
128
- const resourcePart = el.ref.split('/').pop();
129
- if (resourcePart.indexOf('.') === -1) {
130
- // convert reference for database objects only
131
- data[key] = el.ref.split('/').pop();
132
- }
133
- }
134
- });
135
- }
136
- return data;
104
+ return this._resolveNativeForeignKeys(data);
137
105
  }
138
106
  /**
139
107
  * Ensure the collection table exists in SQLite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/backend-sqlite",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "Backend adapter for SQLite",
6
6
  "main": "dist/index.js",
@@ -20,15 +20,15 @@
20
20
  },
21
21
  "author": "Quatrain Développement SAS <developers@quatrain.com>",
22
22
  "dependencies": {
23
- "@quatrain/backend": "^1.2.7",
24
- "@quatrain/core": "^1.2.5",
23
+ "@quatrain/backend": "^1.2.12",
24
+ "@quatrain/core": "^1.2.14",
25
25
  "sqlite": "^5.1.1",
26
26
  "sqlite3": "^5.1.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@faker-js/faker": "^7.6.0",
30
30
  "@jest/expect": "^30.0.0",
31
- "@quatrain/testing": "^1.1.3",
31
+ "@quatrain/testing": "^1.1.4",
32
32
  "@tsconfig/recommended": "^1.0.1",
33
33
  "@types/jest": "^29.5.12",
34
34
  "@types/node": "^22.10.1",
@@ -17,7 +17,6 @@ import {
17
17
  Filter,
18
18
  SortAndLimit,
19
19
  Sorting,
20
- CollectionHierarchy,
21
20
  } from '@quatrain/backend'
22
21
  import { randomUUID } from 'node:crypto'
23
22
  import sqlite3, { Statement } from 'sqlite3'
@@ -53,31 +52,7 @@ export class SQLiteAdapter extends AbstractBackendAdapter {
53
52
  this._dbPath = (params.config?.database as string) || ':memory:'
54
53
  }
55
54
 
56
- protected _buildPath(dataObject: DataObjectClass<any>, uid?: string) {
57
- const collection = this.getCollection(dataObject)
58
- if (!collection) {
59
- throw new BackendError(
60
- `[SQLA] Can't define record path without a collection name`
61
- )
62
- }
63
-
64
- // define document path
65
- let path = `${collection}/${uid}`
66
- if (
67
- this._params.hierarchy &&
68
- this._params.hierarchy[collection] ===
69
- CollectionHierarchy.SUBCOLLECTION &&
70
- dataObject.parentProp &&
71
- dataObject.has(dataObject.parentProp) &&
72
- dataObject.val(dataObject.parentProp)
73
- ) {
74
- path = `${dataObject.val(dataObject.parentProp).path}/${path}`
75
- }
76
-
77
- Backend.info(`[SQLA] Record path is '${path}'`)
78
55
 
79
- return path
80
- }
81
56
 
82
57
  /**
83
58
  * Executes an arbitrary raw SQL query against the SQLite database.
@@ -137,26 +112,7 @@ export class SQLiteAdapter extends AbstractBackendAdapter {
137
112
  }
138
113
  })
139
114
 
140
- if (
141
- this._params['useNativeForeignKeys'] &&
142
- this._params['useNativeForeignKeys'] === true
143
- ) {
144
- data.forEach((el: any, key: number) => {
145
- if (
146
- typeof el === 'object' &&
147
- el !== null &&
148
- Reflect.has(el, 'ref')
149
- ) {
150
- const resourcePart = el.ref.split('/').pop()
151
- if (resourcePart.indexOf('.') === -1) {
152
- // convert reference for database objects only
153
- data[key] = el.ref.split('/').pop()
154
- }
155
- }
156
- })
157
- }
158
-
159
- return data
115
+ return this._resolveNativeForeignKeys(data)
160
116
  }
161
117
 
162
118
  /**