Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
chore(readme): Generated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
oed committed May 8, 2019
1 parent 837d633 commit e2b5dcb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ await box.private.set('email', 'oed@email.service')
await box.private.remove('email')
```

##### Set multiple fields at once:
```js
const fields = ['name', 'website', 'employer']
const values = ['Jon Schwartz', 'openworklabs.com', 'Open Work Labs']

await box.public.setMultiple(fields, values)

const privateFields = ['age', 'coinBalance']
const privateValues = ['xxx', 'yyy']

await box.private.setMultiple(privateFields, privateValues)
```

<!-- commenting this out for now, not really needed when we're not using the iframe
#### IPFS Configs
Expand Down Expand Up @@ -143,7 +156,7 @@ For the fully detailed spec, view the [documentation](https://github.com/3box/3b
**WARNING: this is an experimental feature, the API will likely change in the future!**

#### Viewing a Thread
You can get all posts made in a thread without opening a space. This is great for allowing visitors of your site view comments made by other users. This is achieved by calling the `getThread` method on the Box object.
You can get all posts made in a thread without opening a space. This is great for allowing visitors of your site view comments made by other users. This is achieved by calling the `getThread` method on the Box object.
```js
const posts = await Box.getThread(spaceName, threadName)
console.log(posts)
Expand Down Expand Up @@ -518,6 +531,7 @@ Check if the given address is logged in
* [.get(key)](#KeyValueStore+get) ⇒ <code>String</code>
* [.getMetadata(key)](#KeyValueStore+getMetadata) ⇒ <code>Metadata</code>
* [.set(key, value)](#KeyValueStore+set) ⇒ <code>Boolean</code>
* [.setMultiple(keys, values)](#KeyValueStore+setMultiple) ⇒ <code>Boolean</code>
* [.remove(key)](#KeyValueStore+remove) ⇒ <code>Boolean</code>
<a name="new_KeyValueStore_new"></a>
Expand Down Expand Up @@ -577,6 +591,19 @@ Set a value for the given key
| key | <code>String</code> | the key |
| value | <code>String</code> | the value |
<a name="KeyValueStore+setMultiple"></a>
#### keyValueStore.setMultiple(keys, values) ⇒ <code>Boolean</code>
Set multiple values for multiple keys
**Kind**: instance method of [<code>KeyValueStore</code>](#KeyValueStore)
**Returns**: <code>Boolean</code> - true if successful, throw error if not
| Param | Type | Description |
| --- | --- | --- |
| keys | <code>Array.&lt;String&gt;</code> | the keys |
| values | <code>Array.&lt;String&gt;</code> | the values |
<a name="KeyValueStore+remove"></a>
#### keyValueStore.remove(key) ⇒ <code>Boolean</code>
Expand Down
2 changes: 1 addition & 1 deletion src/publicStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProfileStore extends KeyValueStore {
return super.set(key, value)
}

async setMultiple(keys, values) {
async setMultiple (keys, values) {
throwIfNotEqualLenArrays(keys, values)
this._linkProfile()
return super.setMultiple(keys, values)
Expand Down
2 changes: 1 addition & 1 deletion src/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const privateStoreReducer = (store, keyring) => {
setMultiple: async (keys, values) => {
throwIfNotEqualLenArrays(keys, values)
const dbKeys = keys.map(dbKey)
const encryptedEntries = values.map((value, index) => encryptEntry({ key: keys[index], value}))
const encryptedEntries = values.map((value, index) => encryptEntry({ key: keys[index], value }))
return store.setMultiple(dbKeys, encryptedEntries)
},
remove: async key => store.remove(dbKey(key)),
Expand Down

0 comments on commit e2b5dcb

Please sign in to comment.