@live-change/framework
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -134,2 +134,3 @@ const ReactiveDao = require("@live-change/dao") | ||
await service.start(config || {}) | ||
return service | ||
@@ -136,0 +137,0 @@ } |
@@ -238,3 +238,6 @@ const utils = require("../utils.js") | ||
} else { | ||
console.log("PM", params) | ||
let actionProps = params.draft ? await modelRuntime().get(params.draft) : {} | ||
console.log("AP", actionProps) | ||
console.log("DT", data) | ||
delete actionProps.draft | ||
@@ -241,0 +244,0 @@ delete actionProps.draftStep |
@@ -42,2 +42,19 @@ const ReactiveDao = require("@live-change/dao") | ||
indexObjectPath(index, range = {}) { | ||
if(typeof range != 'object' || Array.isArray(range)) { | ||
const values = Array.isArray(range) ? range : [range] | ||
const str = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')+'_' | ||
return this.indexObjectPath(index,{ gte: str, lte: str+'\xFF\xFF\xFF\xFF' }) | ||
} | ||
if(Array.isArray(range)) this.indexObjectPath(index, range.join(',')) | ||
return ['database', 'queryObject', this.service.databaseName, `(${ | ||
async (input, output, { tableName, indexName, range }) => { | ||
const mapper = async (res) => input.table(tableName).object(res.to).get() | ||
await (await input.index(indexName)).range(range).onChange(async (obj, oldObj) => { | ||
output.change(obj && await mapper(obj), oldObj && await mapper(oldObj)) | ||
}) | ||
} | ||
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range }] | ||
} | ||
observable(id) { | ||
@@ -67,2 +84,10 @@ return this.service.dao.observable(this.path(id), ReactiveDao.ObservableValue) | ||
indexObjectObservable(index, range) { | ||
return this.service.dao.observable(this.indexObjectPath(index, range)) | ||
} | ||
async indexObjectGet(index, range) { | ||
return this.service.dao.get(this.indexObjectPath(index, range)) | ||
} | ||
async update(id, data, options) { | ||
@@ -103,3 +128,3 @@ const operations = Array.isArray(data) ? data : [{ op:'merge', property: null, value: data }] | ||
async handleChange(newObj, oldObj) { | ||
//let id = (change.old_val && change.old_val.id) || (change.new_val && change.new_val.id) | ||
//console.log("HADNLE CHANGE", newObj, oldObj) | ||
//console.log("CHANGE LISTENERS", this.changeListeners) | ||
@@ -106,0 +131,0 @@ for(let listener of this.changeListeners) await listener(newObj, oldObj) |
@@ -133,3 +133,2 @@ const utils = require("../utils.js") | ||
console.log("DELETE TABLE") | ||
console.log("TABLES", tableList, "HAS", tableName, "=>", tableList.indexOf(tableName)) | ||
const model = change.model | ||
@@ -139,5 +138,13 @@ for(let indexName in model.indexes) { | ||
indexName = tableName + '_' + indexName | ||
await dao.request(['database', 'deleteIndex'], database, indexName) | ||
try { | ||
await dao.request(['database', 'deleteIndex'], database, indexName) | ||
} catch(e) { | ||
console.error(e) | ||
} | ||
} | ||
await dao.request(['database', 'deleteTable'], database, tableName) | ||
try { | ||
await dao.request(['database', 'deleteTable'], database, tableName) | ||
} catch(e) { | ||
console.error(e) | ||
} | ||
} break | ||
@@ -170,3 +177,7 @@ case "createIndex": { | ||
} | ||
await dao.request(['database', 'deleteIndex'], database, indexName) | ||
try { | ||
await dao.request(['database', 'deleteIndex'], database, indexName) | ||
} catch(e) { | ||
console.error(e) | ||
} | ||
} break | ||
@@ -173,0 +184,0 @@ case "createProperty": { |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101913
2842