{"name":"@redis/json","version":"1.0.4","license":"MIT","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'","build":"tsc","documentation":"typedoc"},"peerDependencies":{"@redis/client":"^1.0.0"},"devDependencies":{"@istanbuljs/nyc-config-typescript":"^1.0.2","@redis/test-utils":"*","@types/node":"^18.7.10","nyc":"^15.1.0","release-it":"^15.3.0","source-map-support":"^0.5.21","ts-node":"^10.9.1","typedoc":"^0.23.10","typescript":"^4.7.4"},"gitHead":"5dd7d3149a633b762ece0ce8006ecbb4311a547f","description":"This package provides support for the [RedisJSON](https://redisjson.io) module, which adds JSON as a native data type to Redis.  It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the RedisJSON command","_id":"@redis/json@1.0.4","_nodeVersion":"18.4.0","_npmVersion":"8.12.1","dist":{"integrity":"sha512-LUZE2Gdrhg0Rx7AN+cZkb1e6HjoSKaeeW8rYnt89Tly13GBI5eP4CwDVr+MY8BAYfCg4/N15OUrtLoona9uSgw==","shasum":"f372b5f93324e6ffb7f16aadcbcb4e5c3d39bda1","tarball":"http://registry-npm.ywwl.com/@redis/json/download/@redis/json-1.0.4.tgz","fileCount":46,"unpackedSize":23117,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFM7DA/8MYmDu6CDthD26nHBVQtdwNLixjn1u2kWtz8QIhANObZnhZZasnIl+xxhXoXI6w/A0TeAtlRYgJ51u0v8Mu"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFvl2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmppvg//VK0f6TQpa2SUnbVkjImHcmwSLCA36Bcrw1HtuJ6IBeCN9gC3\r\nQjXgPSK5WW6h9CIUCgA113tXFDt6tuFoFXSW3NDqqp26HnN1/EhA7BpK/7yT\r\nbAx9wajV64auq6O4GyYgL/vuJtdaevJTDm6xHpXQl11e5epzwUWn1jw79dmR\r\nGRO/WJyqweAPB4n37wPYxSbfeOYsf+4l6OgY+Rb0OphJ7OE9Vg4EJ3deDcIg\r\nBBScZVG9VFXNmPA1iZsL3yZMZmrHIl868f/8x+KGszZK+CMDlzO353qXerDp\r\nrOV9wP7fHcZz9yVaT23gwGc/6KSl1VMKXj+A8DGN1XQWz6xOklA4Im9MOgtM\r\nrgPDBTH2D/VEVg+CcBnc16EAlEOvMgaHwQENpRyIL7t4lCgG8EPd+xfSN7u6\r\n0fmX6rgdk5zK0Wj9WsthbdrQ1ReIEFfhHWqzcDeFH32APal4n2aZmrzXwL28\r\nV1d5OdVih0L0t1dtXqMbkFwUylHzAozRgVhzfhTD5QILr7TT0HFXTRV2F5Zs\r\ngUXIK/ixQEVrCtwvWZCPyukfHYZ45oz6g1l5ompk8M7gYbqFUMz5BChlHLpn\r\ni0fA00gKahC24SCpdE+13bKwSSRmFS+vti7lCjUPPDOQG0ZX3P0jETnpBRu5\r\nXclB4QY7NV5ii2SwXF1ZVlatqrMMayqAhyk=\r\n=C56f\r\n-----END PGP SIGNATURE-----\r\n","size":4883,"noattachment":false,"key":"/@redis/json/-/@redis/json-1.0.4.tgz"},"_npmUser":{"name":"leibale","email":"leibale1998@gmail.com"},"directories":{},"maintainers":[{"name":"leibale","email":"leibale1998@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json_1.0.4_1662450038645_0.48590693641516136"},"_hasShrinkwrap":false,"readme":"# @redis/json\n\nThis package provides support for the [RedisJSON](https://redis.io/docs/stack/json/) module, which adds JSON as a native data type to Redis.  It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the RedisJSON commands.\n\nTo use these extra commands, your Redis server must have the RedisJSON module installed.\n\n## Usage\n\nFor a complete example, see [`managing-json.js`](https://github.com/redis/node-redis/blob/master/examples/managing-json.js) in the Node Redis examples folder.\n\n### Storing JSON Documents in Redis\n\nThe [`JSON.SET`](https://redis.io/commands/json.set/) command stores a JSON value at a given JSON Path in a Redis key.\n\nHere, we'll store a JSON document in the root of the Redis key \"`mydoc`\":\n\n```javascript\nimport { createClient } from 'redis';\n\n...\nawait client.json.set('noderedis:jsondata', '$', {\n  name: 'Roberta McDonald',\n  pets: [\n    {\n    name: 'Rex',\n    species: 'dog',\n    age: 3,\n    isMammal: true\n    },\n    {\n    name: 'Goldie',\n    species: 'fish',\n    age: 2,\n    isMammal: false\n    }\n  ]\n});\n```\n\nFor more information about RedisJSON's path syntax, [check out the documentation](https://redis.io/docs/stack/json/path/).\n\n### Retrieving JSON Documents from Redis\n\nWith RedisJSON, we can retrieve all or part(s) of a JSON document using the [`JSON.GET`](https://redis.io/commands/json.get/) command and one or more JSON Paths.  Let's get the name and age of one of the pets:\n\n```javascript\nconst results = await client.json.get('noderedis:jsondata', {\n  path: [\n    '.pets[1].name',\n    '.pets[1].age'\n  ]\n});\n```\n\n`results` will contain the following:\n\n```javascript\n { '.pets[1].name': 'Goldie', '.pets[1].age': 2 }\n```\n\n### Performing Atomic Updates on JSON Documents Stored in Redis\n\nRedisJSON includes commands that can atomically update values in a JSON document, in place in Redis without having to first retrieve the entire document.\n\nUsing the [`JSON.NUMINCRBY`](https://redis.io/commands/json.numincrby/) command, we can update the age of one of the pets like this:\n\n```javascript\nawait client.json.numIncrBy('noderedis:jsondata', '.pets[1].age', 1);\n```\n\nAnd we can add a new object to the pets array with the [`JSON.ARRAPPEND`](https://redis.io/commands/json.arrappend/) command:\n\n```javascript\nawait client.json.arrAppend('noderedis:jsondata', '.pets', {\n  name: 'Robin',\n  species: 'bird',\n  age: 1,\n  isMammal: false\n});\n```\n","publish_time":1662450038793,"_cnpm_publish_time":1662450038793,"dist-tags":{"beta":"6.4.0-beta.0","latest":"6.3.1","next":"5.0.0-next.7"}}