stateless interface example
class Database { | |
constructor (storage) { | |
this.count = 0 | |
this.storage = storage | |
} | |
async get (cid) { | |
this.count += 1 | |
return this.storage.get(cid.toBaseEncodedString()) | |
} | |
async put (block) { | |
this.count += 1 | |
return this.storage.put(block.cid.toBaseEncodedString(), block.data) | |
} | |
} | |
let db = new Datebase() | |
let _get = cid => db.get(cid) | |
let selectorString = '/SOME-CID/path' | |
for await (let block of ipld.query(selectorString, _get)) { | |
await db.put(block) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment