rename vars

master
Matthew Huntington 2 years ago
parent 1e8452a383
commit f2b3acd1d0

@ -1,6 +1,6 @@
import { createClient } from 'redis'; import { createClient } from 'redis';
const client = createClient({ const redis = createClient({
password: process.env.REDIS_PWD, password: process.env.REDIS_PWD,
socket: { socket: {
host: 'redis-11789.c329.us-east4-1.gce.redns.redis-cloud.com', host: 'redis-11789.c329.us-east4-1.gce.redns.redis-cloud.com',
@ -8,23 +8,23 @@ const client = createClient({
} }
}); });
await client.connect(); await redis.connect();
console.log('connected'); console.log('connected');
//await client.set('foo', 'bar'); //await redis.set('foo', 'bar');
//const value = await client.get('foo'); //const value = await redis.get('foo');
//console.log(value) // returns 'bar' //console.log(value) // returns 'bar'
//await client.hSet('viv', { //await redis.hSet('viv', {
//name: 'Vivienne', //name: 'Vivienne',
//age: 6 //age: 6
//}) //})
//const viv = await client.hGetAll('viv'); //const viv = await redis.hGetAll('viv');
//const vivAge = await client.hGet('viv', 'age'); //const vivAge = await redis.hGet('viv', 'age');
//console.log(viv); //console.log(viv);
//console.log(vivAge); //console.log(vivAge);
//await client.json.set('matt', '$', { //await redis.json.set('matt', '$', {
//name:'Matt', //name:'Matt',
//age: 43, //age: 43,
//daughter: { //daughter: {
@ -32,19 +32,19 @@ console.log('connected');
//age: 6 //age: 6
//} //}
//}) //})
//const animal = await client.json.get('animal', '$') //const animal = await redis.json.get('animal', '$')
//console.log(animal); //console.log(animal);
import pg from 'pg' import pg from 'pg'
const { Client } = pg const { Client } = pg
const pgClient = new Client({ const postgres = new Client({
database:'lepr_stack' database:'lepr_stack'
}) })
await pgClient.connect() await postgres.connect()
const results = await pgClient.query('SELECT pets.*, people.first_name, people.last_name, people.age AS owner_age FROM pets JOIN people ON pets.owner_id = pets.id') const results = await postgres.query('SELECT pets.*, people.first_name, people.last_name, people.age AS owner_age FROM pets JOIN people ON pets.owner_id = pets.id')
const fluffy = { const fluffy = {
id: results.rows[0].id, id: results.rows[0].id,
name:results.rows[0].name, name:results.rows[0].name,
@ -58,7 +58,7 @@ const fluffy = {
} }
} }
console.log(fluffy); console.log(fluffy);
await client.json.set('fluffy', '$', fluffy) await redis.json.set('fluffy', '$', fluffy)
await pgClient.end() await postgres.end()
await client.disconnect(); await redis.disconnect();

Loading…
Cancel
Save