@live-change/db 0.9.150 → 0.9.152

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/Database.js CHANGED
@@ -235,6 +235,25 @@ class Database {
235
235
  return summary
236
236
  }
237
237
 
238
+ async deleteOpLogs() {
239
+ let promises = []
240
+ for(let name in this.config.tables) promises.push((async (name) => {
241
+ const result = await this.table(name).deleteOpLog()
242
+ return { ...result, type: 'table', name }
243
+ })(name))
244
+ for(let name in this.config.indexes) promises.push((async (name) => {
245
+ try {
246
+ const index = await this.index(name)
247
+ const result = await index.deleteOpLog()
248
+ return { ...result, type: 'index', name }
249
+ } catch(error) {
250
+ return { type: 'index', name }
251
+ }
252
+ })(name))
253
+ const results = await Promise.all(promises)
254
+ return results
255
+ }
256
+
238
257
  async index(name) {
239
258
  let index = this.indexes.get(name)
240
259
  if(!index) {
package/lib/Table.js CHANGED
@@ -125,6 +125,16 @@ class Table {
125
125
  return removedStats
126
126
  }
127
127
 
128
+ async deleteOpLog() {
129
+ const config = this.configObservable.value
130
+ this.database.deleteStore(config.uid + '.opLog')
131
+ this.database.stores.delete(config.uid + '.opLog')
132
+ this.opLog = this.database.store(config.uid + '.opLog', { ...config, ...config.opLog })
133
+ this.opLogWritter = opLogWritter(this.opLog)
134
+ this.opLogger = new OpLogger(this.data, this.opLogWritter)
135
+ this.atomicWriter = new AtomicWriter(this.opLogger)
136
+ }
137
+
128
138
  async synchronized(key, code) {
129
139
  let promise = this.locks.get(key)
130
140
  while(promise) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/db",
3
- "version": "0.9.150",
3
+ "version": "0.9.152",
4
4
  "description": "Database with observable data for live queries",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  "type": "module",
23
23
  "homepage": "https://github.com/live-change/live-change-stack",
24
24
  "devDependencies": {
25
- "@live-change/db-store-level": "^0.9.150",
26
- "@live-change/db-store-lmdb": "^0.9.150",
25
+ "@live-change/db-store-level": "^0.9.152",
26
+ "@live-change/db-store-lmdb": "^0.9.152",
27
27
  "minimist": ">=1.2.3",
28
28
  "next-tick": "^1.1.0",
29
29
  "rimraf": "^5.0.5",
@@ -32,10 +32,10 @@
32
32
  "websocket-extensions": ">=0.1.4"
33
33
  },
34
34
  "dependencies": {
35
- "@live-change/dao": "^0.9.150",
36
- "@live-change/serialization": "^0.9.150",
35
+ "@live-change/dao": "^0.9.152",
36
+ "@live-change/serialization": "^0.9.152",
37
37
  "get-random-values": "^1.2.2",
38
38
  "node-interval-tree": "^1.3.3"
39
39
  },
40
- "gitHead": "afce76f04b77e2435387874255a6ee67f0e7aed8"
40
+ "gitHead": "8252e4e0575937d0ccc334fad5cc40790a11d934"
41
41
  }