Skip to content

Commit

Permalink
Merge pull request #85 from textileio/andrew/support-newDB
Browse files Browse the repository at this point in the history
threads: update to new api with newStore=>newDB
  • Loading branch information
andrewxhill authored Apr 13, 2020
2 parents cf25786 + 23548b4 commit 07b18ba
Show file tree
Hide file tree
Showing 5 changed files with 1,448 additions and 137 deletions.
11 changes: 6 additions & 5 deletions examples/browser/localThreadsDaemon.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@
window.client = api.threadsClient
try {
// Create a new store
const res = await client.newStore()
const storeID = res.id
const threadId = client.ThreadID.fromRandom()
const dbID = threadId.bytes()
const res = await client.newDB(dbID)

// Register a person schema
await client.registerSchema(storeID, 'Person', personSchema)
await client.registerSchema(dbID, 'Person', personSchema)

// Create adam and eve
const people = await client.modelCreate(storeID, 'Person', [adam, eve])
const people = await client.modelCreate(dbID, 'Person', [adam, eve])
const adamID = JSON.parse(people.entitiesList[0]).ID
const eveID = JSON.parse(people.entitiesList[1]).ID
console.debug('adam:', adamID)
console.debug('eve:', eveID)

// Subscribe to adam
await client.listen(storeID, 'Person', adamID, ((reply) => {
await client.listen(dbID, 'Person', adamID, ((reply) => {
console.debug(reply)
}))
}
Expand Down
Loading

0 comments on commit 07b18ba

Please sign in to comment.