mediachain / oldchain-client

[DEPRECATED] old mediachain client experiments
MIT License
4 stars 2 forks source link

Update cell API #78

Open parkan opened 8 years ago

parkan commented 8 years ago

Should take canonical id and new object and attach new chain cell

yusefnapora commented 8 years ago

hrm... so I've got the brain-dead version of this working (accept id and meta dictionary and write the cell with no schema verification, etc). But it looks like the chain folding in the reader api is happening backwards... so the most recently written update cell gets applied first, and the first cell is applied last

will push a branch once that's fixed :)

parkan commented 8 years ago

Sounds like we're missing a reversed!

yusefnapora commented 8 years ago

the more serious issue is that the apply_update_cell clobbers any existing value instead of merging if it's a dictionary... so if an update cell has e.g.

{
  "meta": {
    "data": {
      "foo": "bar"
    }
  }
}

it will overwrite all the existing meta.data 😛

pretty simple to merge the cell['meta'] into object['meta'] instead. For keys in both, the value in the chain cell will win. I've got that working, but I haven't done anything about arrays yet... if you wanted to e.g. add a keyword, and the update cell has an array with one string in it, it will overwrite the existing keywords array, which might not be what you expect...

parkan commented 8 years ago

@yusefnapora I think @autoencoder has some general-purpose recursive merging code that respects nulls and empty values in the indexer schema utils

parkan commented 8 years ago

(similar to jQuery's $.extend(...)

yusefnapora commented 8 years ago

sweet, we should maybe pull those into the client