Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Conversation

@haydenyoung
Copy link
Member

To test:

create a keyvalue store:

curl http://localhost:3000/db/keyvalue --data 'create=true' --data 'type=keyvalue'

write a key/object-value to the store:

curl -X POST http://localhost:3000/db/keyvalue/put -H "Content-Type: application/json" -d '{"key":"mykey","value":"{ name: \"World\" }"}'

It should correctly parse the JSON and store a JS object against the key.

A simple:

console.log(db._index)

should show the full list correctly written to the keyvalue store.

@phillmac phillmac self-requested a review April 7, 2019 23:50
Copy link
Contributor

@phillmac phillmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant json.parse


if (db.type == 'keyvalue') {
let params = req.body;
hash = await db.put(params.key, JSON.parse(params.value))
Copy link
Contributor

@phillmac phillmac Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse is redundant here, the json parser instruction on L14 means that the whole params var is already an unpacked object and no longer a string to be parsed.

hash = await db.put(params.key, params.value)

@phillmac phillmac merged commit 907e4d1 into master Apr 8, 2019
@phillmac phillmac deleted the POST-put-keyvalue branch April 28, 2019 11:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants