Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@live-change/framework

Package Overview
Dependencies
Maintainers
0
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/framework - npm Package Compare versions

Comparing version 0.8.34 to 0.8.35

20

lib/updaters/database.js

@@ -65,4 +65,5 @@ import * as utils from "../utils.js"

if(Array.isArray(index.property)) throw new Error("multi indexes on multiple properties are not supported!")
const func = async function(input, output, { table, property }) {
const values = (obj) => {
const properties = (Array.isArray(index.property) ? index.property : [index.property]).map(p => p.split('.'))
const func = async function(input, output, { table, properties }) {
const value = (obj, property) => {
let at = obj

@@ -74,6 +75,11 @@ for(const p of property) at = at && at[p]

}
const keys = (obj, id) => {
const values = value(obj, properties[id])
if(id === properties.length - 1) return values
return values.flatMap(v => keys(obj, id + 1).map(k => v + ':' + k))
}
await input.table(table).onChange((obj, oldObj) => {
if(obj && oldObj) {
let pointers = obj && new Set(values(obj))
let oldPointers = oldObj && new Set(values(oldObj))
let pointers = obj && new Set(keys(obj))
let oldPointers = oldObj && new Set(keys(oldObj))
for(let pointer of pointers) {

@@ -86,5 +92,5 @@ if(!!oldPointers.has(pointer)) output.change({ id: pointer+'_'+obj.id, to: obj.id }, null)

} else if(obj) {
values(obj).forEach(v => output.change({ id: v+'_'+obj.id, to: obj.id }, null))
keys(obj).forEach(k => output.change({ id: k+'_'+obj.id, to: obj.id }, null))
} else if(oldObj) {
values(oldObj).forEach(v => output.change(null, { id: v+'_'+oldObj.id, to: oldObj.id }))
keys(oldObj).forEach(k => output.change(null, { id: k+'_'+oldObj.id, to: oldObj.id }))
}

@@ -96,3 +102,3 @@ })

await dao.requestWithSettings(indexRequestSettings, ['database', 'createIndex'], database, indexName,
functionCode, { property: index.property.split('.'), table }, index.storage ?? {})
functionCode, { properties, table }, index.storage ?? {})
} else {

@@ -99,0 +105,0 @@ if(!table) throw new Error("only function indexes are possible without table")

{
"name": "@live-change/framework",
"version": "0.8.34",
"version": "0.8.35",
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",

@@ -25,6 +25,6 @@ "main": "index.js",

"devDependencies": {
"@live-change/dao": "^0.8.34",
"@live-change/uid": "^0.8.34"
"@live-change/dao": "^0.8.35",
"@live-change/uid": "^0.8.35"
},
"gitHead": "40e61928bf43b35352c76fc135f36a2d8bd76c4a"
"gitHead": "90fbb746dc7270895daf17b437ca48c0b0a01c01"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc