@live-change/db
Advanced tools
Comparing version 0.3.38 to 0.3.39
@@ -11,3 +11,4 @@ const Table = require('./Table.js') | ||
class Database { | ||
constructor(config, storeFactory, saveConfig, deleteStore) { | ||
constructor(config, storeFactory, saveConfig, deleteStore, name) { | ||
this.name = name | ||
this.config = { | ||
@@ -263,4 +264,14 @@ tables: {}, | ||
} | ||
handleUnhandledRejectionInIndex(name, reason, promise) { | ||
const config = this.config.indexes[name] | ||
console.error("INDEX", name, "unhandledRejection", reason, "CODE:\n", config.code) | ||
console.error("DELETING INDEX", name) | ||
delete this.config.indexes[name] | ||
this.indexesListObservable.remove(name) | ||
if(this.onAutoRemoveIndex) this.onAutoRemoveIndex(name, config.uid) | ||
this.saveConfig(this.config) | ||
} | ||
} | ||
module.exports = Database |
@@ -366,2 +366,3 @@ const IntervalTree = require('node-interval-tree').default | ||
super(database, name, config) | ||
this.database = database | ||
this.codeObservable = new ReactiveDao.ObservableValue(code) | ||
@@ -376,3 +377,3 @@ this.params = params | ||
}) | ||
const queryFunction = this.scriptContext.run(this.code, 'query') | ||
const queryFunction = this.scriptContext.run(this.code,`userCode:${this.database.name}/indexes/${name}`) | ||
this.codeFunction = (input, output) => queryFunction(input, output, this.params) | ||
@@ -379,0 +380,0 @@ this.writer = new IndexWriter(this) |
{ | ||
"name": "@live-change/db", | ||
"version": "0.3.38", | ||
"version": "0.3.39", | ||
"description": "Database with observable data for live queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
84504
2532