@ -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 p gClient = new Client ( {
const p ostgres = new Client ( {
database : 'lepr_stack'
} )
await p gClient . connect ( )
await p ostgres . connect ( )
const results = await p gClient . 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 p ostgres . 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 p gClient . end ( )
await client . disconnect ( ) ;
await redis . json . set ( 'fluffy' , '$' , fluffy )
await p ostgres . end ( )
await redis . disconnect ( ) ;