You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
704 B

import redis from './redis.js'
import postgres from './postgres.js'
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 fluffy = {
id: results.rows[0].id,
name:results.rows[0].name,
species:results.rows[0].species,
age: results.rows[0].age,
owner: {
id:results.rows[0].owner_id,
first_name:results.rows[0].first_name,
last_name:results.rows[0].last_name,
age:results.rows[0].owner_age
}
}
console.log(fluffy);
await redis.json.set('fluffy', '$', fluffy)
}
await runExample()
await postgres.end()
await redis.disconnect();