deepbase-sqlite 3.0.8 → 3.1.0
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 +2 -2
- package/src/SqliteDriver.js +0 -8
- package/test/test.js +59 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepbase-sqlite",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "⚡ DeepBase SQLite - SQLite database driver",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.cjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"better-sqlite3": "^11.8.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"deepbase": "^3.0
|
|
18
|
+
"deepbase": "^3.1.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "mocha test/test.js"
|
package/src/SqliteDriver.js
CHANGED
|
@@ -156,14 +156,6 @@ export class SqliteDriver extends DeepBaseDriver {
|
|
|
156
156
|
return this.set(...args, func(await this.get(...args)));
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
_pathToKey(path) {
|
|
160
|
-
return path.join('.');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
_keyToPath(key) {
|
|
164
|
-
return key.split('.');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
159
|
_getRootObject() {
|
|
168
160
|
const rows = this.getAllStmt.all();
|
|
169
161
|
const result = {};
|
package/test/test.js
CHANGED
|
@@ -97,6 +97,65 @@ describe('SqliteDriver', function() {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
+
describe('Keys with Dots', function() {
|
|
101
|
+
it('should handle keys containing dots', async function() {
|
|
102
|
+
const setResult = await db.set('value', 'martin.clasen@gmail.com', 1);
|
|
103
|
+
|
|
104
|
+
assert.strictEqual(setResult.length, 2);
|
|
105
|
+
assert.strictEqual(setResult[0], 'value');
|
|
106
|
+
assert.strictEqual(setResult[1], 'martin.clasen@gmail.com');
|
|
107
|
+
|
|
108
|
+
const getValue = await db.get('value');
|
|
109
|
+
assert.deepStrictEqual(getValue, { 'martin.clasen@gmail.com': 1 });
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should handle keys with multiple dots', async function() {
|
|
113
|
+
await db.set('config', 'api.prod.endpoint', 'https://api.example.com');
|
|
114
|
+
const endpoint = await db.get('config', 'api.prod.endpoint');
|
|
115
|
+
assert.strictEqual(endpoint, 'https://api.example.com');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should handle nested paths with dots in keys', async function() {
|
|
119
|
+
await db.set('users', 'john.doe@example.com', 'name', 'John Doe');
|
|
120
|
+
await db.set('users', 'john.doe@example.com', 'age', 30);
|
|
121
|
+
|
|
122
|
+
const user = await db.get('users', 'john.doe@example.com');
|
|
123
|
+
assert.deepStrictEqual(user, { name: 'John Doe', age: 30 });
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should handle dots in first level keys', async function() {
|
|
127
|
+
await db.set('config.prod', 'value', 100);
|
|
128
|
+
const configProd = await db.get('config.prod');
|
|
129
|
+
assert.deepStrictEqual(configProd, { value: 100 });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should distinguish between dots in keys and path separators', async function() {
|
|
133
|
+
// Set a regular nested path
|
|
134
|
+
await db.set('users', 'alice', 'email', 'alice@example.com');
|
|
135
|
+
|
|
136
|
+
// Set a key with dots at the same level
|
|
137
|
+
await db.set('users', 'john.doe@company.com', 'email', 'john@work.com');
|
|
138
|
+
|
|
139
|
+
const users = await db.get('users');
|
|
140
|
+
assert.strictEqual(users.alice.email, 'alice@example.com');
|
|
141
|
+
assert.strictEqual(users['john.doe@company.com'].email, 'john@work.com');
|
|
142
|
+
assert.strictEqual(Object.keys(users).length, 2);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should delete keys containing dots', async function() {
|
|
146
|
+
await db.set('emails', 'user.name@domain.com', 'verified', true);
|
|
147
|
+
await db.set('emails', 'other@email.com', 'verified', false);
|
|
148
|
+
|
|
149
|
+
await db.del('emails', 'user.name@domain.com');
|
|
150
|
+
|
|
151
|
+
const email1 = await db.get('emails', 'user.name@domain.com');
|
|
152
|
+
const email2 = await db.get('emails', 'other@email.com');
|
|
153
|
+
|
|
154
|
+
assert.strictEqual(email1, null);
|
|
155
|
+
assert.deepStrictEqual(email2, { verified: false });
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
100
159
|
describe('Delete Operations', function() {
|
|
101
160
|
it('should delete a key', async function() {
|
|
102
161
|
await db.set('temp', 'value');
|