Skip to content

DOC-2737 - Adds JSON examples for Node.js #2642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: emb-examples
Choose a base branch
from

Conversation

justincastilla
Copy link

Description

Addresses this ticket:
https://redislabs.atlassian.net/browse/DOC-2737

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

createClient
} from 'redis';

const client = await createClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty sure this wont add json to the client. should need to specify it as a module on the client.

console.log(res2); // "Hyperion"

const res3 = await client.json.type("bike", "$");
console.log(res3); // [ 'string' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

testing against v5, and in v5, this returns it outside of array syntax. need to understand what's going on.

// STEP_END

// REMOVE_START
assert.equal(res2, '"Hyperion"');
Copy link
Contributor

Choose a reason for hiding this comment

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

in v5, getting an error due to escaping of quotes it seems. unsure why


// STEP_START num
const res7 = await client.json.set("crashes", "$", 0);
console.log(res7) // True
Copy link
Contributor

Choose a reason for hiding this comment

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

we get back OK which seems right, not True. doesn't seem that different from line 16

const res12 = await client.json.get("newbike", "$");
console.log(res12); // ['["Deimos", { "crashes": 0 }, null]']

const res13 = await client.json.get("newbike", "$[1].crashes");
Copy link
Contributor

Choose a reason for hiding this comment

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

this returns same as above for me in v5

console.log(res14); // [1]

const res15 = await client.json.get("newbike", "$");
console.log(res15); // [['Deimos', {'crashes': 0}]]
Copy link
Contributor

Choose a reason for hiding this comment

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

this returns null for me, which I think is what I'd expect after above command?

const res22 = await client.json.get("riders", "$");
console.log(res22); // [['Prickett']]

const res23 = await client.json.arrPop("riders", "$");
Copy link
Contributor

Choose a reason for hiding this comment

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

this changes in v5, the path is in a struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants