diff --git a/server.js b/server.js index e7501aa..ce2ed18 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,6 @@ import { createClient } from 'redis'; -const client = createClient({ +const redis = createClient({ password: process.env.REDIS_PWD, socket: { 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'); -//await client.set('foo', 'bar'); -//const value = await client.get('foo'); +//await redis.set('foo', 'bar'); +//const value = await redis.get('foo'); //console.log(value) // returns 'bar' -//await client.hSet('viv', { +//await redis.hSet('viv', { //name: 'Vivienne', //age: 6 //}) -//const viv = await client.hGetAll('viv'); -//const vivAge = await client.hGet('viv', 'age'); +//const viv = await redis.hGetAll('viv'); +//const vivAge = await redis.hGet('viv', 'age'); //console.log(viv); //console.log(vivAge); -//await client.json.set('matt', '$', { +//await redis.json.set('matt', '$', { //name:'Matt', //age: 43, //daughter: { @@ -32,19 +32,19 @@ console.log('connected'); //age: 6 //} //}) -//const animal = await client.json.get('animal', '$') +//const animal = await redis.json.get('animal', '$') //console.log(animal); import pg from 'pg' const { Client } = pg -const pgClient = new Client({ +const postgres = new Client({ 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 = { id: results.rows[0].id, name:results.rows[0].name, @@ -58,7 +58,7 @@ const fluffy = { } } console.log(fluffy); -await client.json.set('fluffy', '$', fluffy) -await pgClient.end() -await client.disconnect(); +await redis.json.set('fluffy', '$', fluffy) +await postgres.end() +await redis.disconnect();