## 2017-06-07 File Table

"What am I writing to do today?" (Marcel T.)

Our File table:

```JS
import Dexie from "https://unpkg.com/dexie@2.0.0-beta.11/dist/dexie.js"
var db = new Dexie("file_cache");
db.version(1).stores({
    files: 'url,name,type,version,content,title,tags'
})
```

Update the table:
```JS
import Strings from "src/client/strings.js"
db.files.where("name").notEqual("").modify(function(ea) {
    ea.title = ea.content.split("\n")[0].replace(/## /,"") 
    ea.tags = Strings.matchAll('#[A-Za-z0-9]+', ea.content)
})
```


Show results in "that" table....

```JS
var result= []
db.files.each(ea => {
  result.push(
    {name:ea.name, 
    size: ea.content.length, 
    title: ea.title, 
    tags: ea.tags})
}).then(() => {
  var table = that;
  table.setFromJSO(result)
  table.style.overflow = "auto"
  table.column("size").forEach(cell => cell.classList.add("number"))
})
```

