reorg multiple files

master
Matthew Huntington 2 years ago
parent 0853fb6f34
commit 5166710365

@ -0,0 +1,13 @@
import pg from 'pg'
const connectPostgres = async ()=>{
const { Client } = pg
const postgres = new Client({
database:'lepr_stack'
})
await postgres.connect()
console.log('connected to pg');
return postgres
}
export default await connectPostgres()

@ -0,0 +1,14 @@
import { createClient } from 'redis';
const connectRedis = async ()=>{
const redis = createClient({
password: process.env.REDIS_PWD,
socket: {
host: 'redis-11789.c329.us-east4-1.gce.redns.redis-cloud.com',
port: 11789
}
});
await redis.connect();
console.log('connected to redis');
return redis
}
export default await connectRedis()

@ -1,31 +1,5 @@
import { createClient } from 'redis'; import redis from './redis.js'
import pg from 'pg' import postgres from './postgres.js'
const connectRedis = async ()=>{
const redis = createClient({
password: process.env.REDIS_PWD,
socket: {
host: 'redis-11789.c329.us-east4-1.gce.redns.redis-cloud.com',
port: 11789
}
});
await redis.connect();
console.log('connected to redis');
return redis
}
const redis = await connectRedis()
const connectPostgres = async ()=>{
const { Client } = pg
const postgres = new Client({
database:'lepr_stack'
})
await postgres.connect()
console.log('connected to pg');
return postgres
}
const postgres = await connectPostgres()
const runExample = async ()=>{ const runExample = async ()=>{
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 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')

Loading…
Cancel
Save