@live-change/db
Advanced tools
Comparing version
@@ -78,2 +78,11 @@ function getProperty(of, propertyName) { | ||
}, | ||
mergeSets(obj, { property, values }) { | ||
const valuesStrs = values.map(e=>JSON.stringify(e)) | ||
updateProperty(obj, property, v => { | ||
const current = (v ? (Array.isArray(v) ? v : [v]) : []) | ||
const currentStrs = current.map(e=>JSON.stringify(e)) | ||
return Array.from(new Set([...valuesStrs, ...currentStrs])).map(x => JSON.parse(x)) | ||
}) | ||
return obj | ||
}, | ||
add(obj, { property, value }) { | ||
@@ -83,2 +92,16 @@ updateProperty(obj, property, v => (v||0) + value) | ||
}, | ||
max(obj, { property, value }) { | ||
updateProperty(obj, property, v => { | ||
const current = (v || -Infinity) | ||
return current > value ? current : value | ||
}) | ||
return obj | ||
}, | ||
min(obj, { property, value }) { | ||
updateProperty(obj, property, v => { | ||
const current = (v || Infinity) | ||
return current < value ? current : value | ||
}) | ||
return obj | ||
}, | ||
merge(obj, { property, value }) { | ||
@@ -85,0 +108,0 @@ if(property) return updateProperty(obj, property, v => mergeDeep(v, value)) |
{ | ||
"name": "@live-change/db", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"description": "Database with observable data for live queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
73588
1.03%2237
1.04%