Skip to content

Instantly share code, notes, and snippets.

@HugoRoca
Last active December 25, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HugoRoca/75570f290bc894011c307a497c07a52b to your computer and use it in GitHub Desktop.
Save HugoRoca/75570f290bc894011c307a497c07a52b to your computer and use it in GitHub Desktop.
REDIS - set
"use strict";
const redisConnection = require("./redis-connection");
const redis = new redisConnection();
(async () => {
try {
// Para este caso haremos uso de un JSON, tambien se puede guardar string, int, double, etc.
let data = [{
"_id": "5c21d04d34b4a04750f9aa6f",
"index": 0,
"guid": "c9f32788-0116-48e9-86d5-9c7649f70c58",
"friends": [{
"id": 0,
"name": "Tania Cardenas"
},
{
"id": 1,
"name": "Cherry Bishop"
},
{
"id": 2,
"name": "Simpson French"
}
]
},
{
"_id": "5c21d04db527f89279d44902",
"index": 1,
"guid": "144ef286-f059-4a62-98ca-b54c5130a4d7",
"friends": [{
"id": 0,
"name": "Vaughn Ratliff"
},
{
"id": 1,
"name": "Delores Glover"
},
{
"id": 2,
"name": "Jayne Puckett"
}
]
}
];
// NOTA: cuando lo que se quiere registrar es un json o array, debemos de usar el JSON.strinify
await redis.set("dataPrueba", JSON.stringify(data));
} catch (error) {
console.log(`Error al procesar: ${error}`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment