@live-change/db-server 0.9.137 → 0.9.139
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/lib/dbDao.js +93 -0
- package/package.json +14 -14
- package/.nx/cache/lockfile.hash +0 -1
- package/.nx/cache/nx_files.nxt +0 -0
- package/LICENSE.md +0 -11
package/lib/dbDao.js
CHANGED
|
@@ -242,6 +242,23 @@ function localRequests(server, scriptContext) {
|
|
|
242
242
|
if(!db) throw new Error('databaseNotFound')
|
|
243
243
|
const queryFunction = scriptContext.getOrCreateFunction(code, 'query')
|
|
244
244
|
return db.queryUpdate((input, output) => queryFunction(input, output, params))
|
|
245
|
+
},
|
|
246
|
+
runQuery: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
247
|
+
if(dbName === 'system') throw new Error("system database is not writable")
|
|
248
|
+
if(!dbName) throw new Error("databaseNameRequired")
|
|
249
|
+
const db = server.databases.get(dbName)
|
|
250
|
+
if(!db) throw new Error('databaseNotFound')
|
|
251
|
+
const table = db.table(queryCodeTable)
|
|
252
|
+
if(!table) throw new Error("tableNotFound")
|
|
253
|
+
const queryData = await table.objectGet(queryCodeId)
|
|
254
|
+
if(!queryData) throw new Error("queryCodeNotFound")
|
|
255
|
+
const queryCode = queryData.code
|
|
256
|
+
const querySourceName = queryData.sourceName
|
|
257
|
+
const queryFunction = scriptContext.getOrCreateFunction(
|
|
258
|
+
queryCode,
|
|
259
|
+
querySourceName ? querySourceName : 'queryCode:' + queryCodeId
|
|
260
|
+
)
|
|
261
|
+
return db.queryUpdate((input, output) => queryFunction(input, output, params))
|
|
245
262
|
}
|
|
246
263
|
}
|
|
247
264
|
}
|
|
@@ -378,6 +395,14 @@ function remoteRequests(server) {
|
|
|
378
395
|
const db = server.databases.get(dbName)
|
|
379
396
|
if(!db) throw new Error('databaseNotFound')
|
|
380
397
|
return server.masterDao.request(['database', 'query'], dbName, code, params )
|
|
398
|
+
},
|
|
399
|
+
runQuery: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
400
|
+
if(!dbName) throw new Error("databaseNameRequired")
|
|
401
|
+
const db = server.databases.get(dbName)
|
|
402
|
+
if(!db) throw new Error('databaseNotFound')
|
|
403
|
+
const table = db.table(queryCodeTable)
|
|
404
|
+
if(!table) throw new Error("tableNotFound")
|
|
405
|
+
return server.masterDao.request(['database', 'runQuery'], dbName, queryCodeTable, queryCodeId, params)
|
|
381
406
|
}
|
|
382
407
|
}
|
|
383
408
|
}
|
|
@@ -859,6 +884,74 @@ function localReads(server, scriptContext) {
|
|
|
859
884
|
const queryFunction = scriptContext.getOrCreateFunction(code, 'queryCode:' + sourceName)
|
|
860
885
|
return db.queryObjectGet((input, output) => queryFunction(input, output, params))
|
|
861
886
|
}
|
|
887
|
+
},
|
|
888
|
+
runQuery: {
|
|
889
|
+
get: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
890
|
+
if(!dbName) throw new Error("databaseNameRequired")
|
|
891
|
+
const db = server.databases.get(dbName)
|
|
892
|
+
if(!db) throw new Error('databaseNotFound')
|
|
893
|
+
const table = db.table(queryCodeTable)
|
|
894
|
+
if(!table) throw new Error("tableNotFound")
|
|
895
|
+
const queryData = await table.objectGet(queryCodeId)
|
|
896
|
+
if(!queryData) throw new Error("queryCodeNotFound")
|
|
897
|
+
const queryCode = queryData.code
|
|
898
|
+
const querySourceName = queryData.sourceName
|
|
899
|
+
const queryFunction = scriptContext.getOrCreateFunction(
|
|
900
|
+
queryCode,
|
|
901
|
+
querySourceName ? querySourceName : 'queryCode:' + queryCodeId
|
|
902
|
+
)
|
|
903
|
+
return db.queryGet((input, output) => queryFunction(input, output, params))
|
|
904
|
+
},
|
|
905
|
+
observable: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
906
|
+
if(!dbName) return new ReactiveDao.ObservableError("databaseNameRequired")
|
|
907
|
+
const db = server.databases.get(dbName)
|
|
908
|
+
if(!db) return new ReactiveDao.ObservableError('databaseNotFound')
|
|
909
|
+
const table = db.table(queryCodeTable)
|
|
910
|
+
if(!table) return new ReactiveDao.ObservableError('tableNotFound')
|
|
911
|
+
const queryData = await table.objectGet(queryCodeId)
|
|
912
|
+
if(!queryData) throw new Error("queryCodeNotFound")
|
|
913
|
+
const queryCode = queryData.code
|
|
914
|
+
const querySourceName = queryData.sourceName
|
|
915
|
+
const queryFunction = scriptContext.getOrCreateFunction(
|
|
916
|
+
queryCode,
|
|
917
|
+
querySourceName ? querySourceName : 'queryCode:' + queryCodeId
|
|
918
|
+
)
|
|
919
|
+
return db.queryObservable((input, output) => queryFunction(input, output, params))
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
runQueryObject: {
|
|
923
|
+
get: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
924
|
+
if(!dbName) throw new Error("databaseNameRequired")
|
|
925
|
+
const db = server.databases.get(dbName)
|
|
926
|
+
if(!db) throw new Error('databaseNotFound')
|
|
927
|
+
const table = db.table(queryCodeTable)
|
|
928
|
+
if(!table) throw new Error("tableNotFound")
|
|
929
|
+
const queryData = await table.objectGet(queryCodeId)
|
|
930
|
+
if(!queryData) throw new Error("queryCodeNotFound")
|
|
931
|
+
const queryCode = queryData.code
|
|
932
|
+
const querySourceName = queryData.sourceName
|
|
933
|
+
const queryFunction = scriptContext.getOrCreateFunction(
|
|
934
|
+
queryCode,
|
|
935
|
+
querySourceName ? querySourceName : 'queryCode:' + queryCodeId
|
|
936
|
+
)
|
|
937
|
+
return db.queryObjectGet((input, output) => queryFunction(input, output, params))
|
|
938
|
+
},
|
|
939
|
+
observable: async (dbName, queryCodeTable, queryCodeId, params) => {
|
|
940
|
+
if(!dbName) return new ReactiveDao.ObservableError("databaseNameRequired")
|
|
941
|
+
const db = server.databases.get(dbName)
|
|
942
|
+
if(!db) return new ReactiveDao.ObservableError('databaseNotFound')
|
|
943
|
+
const table = db.table(queryCodeTable)
|
|
944
|
+
if(!table) return new ReactiveDao.ObservableError('tableNotFound')
|
|
945
|
+
const queryData = await table.objectGet(queryCodeId)
|
|
946
|
+
if(!queryData) throw new Error("queryCodeNotFound")
|
|
947
|
+
const queryCode = queryData.code
|
|
948
|
+
const querySourceName = queryData.sourceName
|
|
949
|
+
const queryFunction = scriptContext.getOrCreateFunction(
|
|
950
|
+
queryCode,
|
|
951
|
+
querySourceName ? querySourceName : 'queryCode:' + queryCodeId
|
|
952
|
+
)
|
|
953
|
+
return db.queryObjectObservable((input, output) => queryFunction(input, output, params))
|
|
954
|
+
}
|
|
862
955
|
}
|
|
863
956
|
}
|
|
864
957
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/db-server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.139",
|
|
4
4
|
"description": "Database with observable data for live queries",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"vite-plugin-vue-images": "^0.6.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@live-change/dao": "^0.9.
|
|
41
|
-
"@live-change/dao-message": "^0.9.
|
|
42
|
-
"@live-change/dao-sockjs": "^0.9.
|
|
43
|
-
"@live-change/dao-websocket": "^0.9.
|
|
44
|
-
"@live-change/db": "^0.9.
|
|
45
|
-
"@live-change/db-admin": "^0.9.
|
|
46
|
-
"@live-change/db-client": "^0.9.
|
|
47
|
-
"@live-change/db-store-level": "^0.9.
|
|
48
|
-
"@live-change/db-store-lmdb": "^0.9.
|
|
49
|
-
"@live-change/db-store-observable-db": "^0.9.
|
|
50
|
-
"@live-change/db-store-rbtree": "^0.9.
|
|
51
|
-
"@live-change/server": "^0.9.
|
|
40
|
+
"@live-change/dao": "^0.9.139",
|
|
41
|
+
"@live-change/dao-message": "^0.9.139",
|
|
42
|
+
"@live-change/dao-sockjs": "^0.9.139",
|
|
43
|
+
"@live-change/dao-websocket": "^0.9.139",
|
|
44
|
+
"@live-change/db": "^0.9.139",
|
|
45
|
+
"@live-change/db-admin": "^0.9.139",
|
|
46
|
+
"@live-change/db-client": "^0.9.139",
|
|
47
|
+
"@live-change/db-store-level": "^0.9.139",
|
|
48
|
+
"@live-change/db-store-lmdb": "^0.9.139",
|
|
49
|
+
"@live-change/db-store-observable-db": "^0.9.139",
|
|
50
|
+
"@live-change/db-store-rbtree": "^0.9.139",
|
|
51
|
+
"@live-change/server": "^0.9.139",
|
|
52
52
|
"@live-change/sockjs": "0.4.1",
|
|
53
53
|
"@tailwindcss/vite": "^4.1.0",
|
|
54
54
|
"express": "^4.18.2",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"websocket": "^1.0.34",
|
|
59
59
|
"yargs": "^17.7.2"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9202c36abc25e3baf5fe39806d89c3fab203f428"
|
|
62
62
|
}
|
package/.nx/cache/lockfile.hash
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
14138194452193804272
|
package/.nx/cache/nx_files.nxt
DELETED
|
Binary file
|
package/LICENSE.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Copyright 2019-2024 Michał Łaszczewski
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
-
|
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|