Fix examples
This commit is contained in:
parent
91379eb5ee
commit
e043fec8bd
@ -29,16 +29,17 @@
|
||||
const query = () => {
|
||||
const startTime = new Date().getTime()
|
||||
const idx = Math.floor(Math.random() * creatures.length)
|
||||
const creature = creatures[idx] + " " + creatures[idx]
|
||||
|
||||
// Set a key-value pair
|
||||
db.put(key, "db.put #" + count + " - GrEEtinGs to " + creatures[idx])
|
||||
db.put(key, "db.put #" + count + " - GrEEtinGs to " + creature)
|
||||
.then((res) => {
|
||||
const endTime = new Date().getTime()
|
||||
console.log(`db.put (#${count}) took ${(endTime - startTime)} ms\n`)
|
||||
count ++
|
||||
})
|
||||
.then(() => counter.inc()) // Increase the counter by one
|
||||
.then(() => log.add(creatures[idx])) // Add an event to 'latest visitors' log
|
||||
.then(() => log.add(creature)) // Add an event to 'latest visitors' log
|
||||
.then(() => {
|
||||
const result = db.get(key)
|
||||
const latest = log.iterator({ limit: 5 }).collect()
|
||||
@ -70,7 +71,9 @@
|
||||
console.error(e.stack)
|
||||
})
|
||||
}
|
||||
setInterval(query, Math.random() * 3 * 1000)
|
||||
|
||||
// Start query loop when the databse has loaded its history
|
||||
db.events.on('ready', () => setInterval(query, 1000))
|
||||
|
||||
} catch(e) {
|
||||
console.error(e.stack)
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const IpfsApi = require('exports?IpfsApi!ipfs-api/dist/index.js')
|
||||
const IpfsApi = require('exports-loader?IpfsApi!ipfs-api/dist/index.js')
|
||||
const OrbitDB = require('../../src/OrbitDB')
|
||||
|
||||
const username = new Date().getTime()
|
||||
@ -63,7 +63,9 @@ Visitor Count: ${count}
|
||||
console.error(e.stack)
|
||||
})
|
||||
}
|
||||
setInterval(query, Math.random() * 3 * 1000)
|
||||
|
||||
// Start query loop when the databse has loaded its history
|
||||
db.events.on('ready', () => setInterval(query, 1000))
|
||||
|
||||
} catch(e) {
|
||||
console.error(e.stack)
|
||||
|
Loading…
x
Reference in New Issue
Block a user