Skip to content

Commit

Permalink
Update connection string to match the test db (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee authored Aug 1, 2024
1 parent 1449088 commit 2f692d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const mongoose = require("mongoose");
mongoose.set("strictQuery", false);

const dev_db_url =
"mongodb+srv://cooluser:coolpassword@cluster0.lz91hw2.mongodb.net/local_library?retryWrites=true&w=majority";
"mongodb+srv://cooluser:coolpassword@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0";
const mongoDB = process.env.MONGODB_URI || dev_db_url;

main().catch((err) => console.log(err));
Expand Down
49 changes: 34 additions & 15 deletions populatedb.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env node

console.log(
'This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: node populatedb "mongodb+srv://cooluser:coolpassword@cluster0.lz91hw2.mongodb.net/local_library?retryWrites=true&w=majority"'
'This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: node populatedb "mongodb+srv://cooluser:coolpassword@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0"'
);

// Get arguments passed on command line
Expand Down Expand Up @@ -110,49 +110,56 @@ async function createAuthors() {
async function createBooks() {
console.log("Adding Books");
await Promise.all([
bookCreate(0,
bookCreate(
0,
"The Name of the Wind (The Kingkiller Chronicle, #1)",
"I have stolen princesses back from sleeping barrow kings. I burned down the town of Trebon. I have spent the night with Felurian and left with both my sanity and my life. I was expelled from the University at a younger age than most people are allowed in. I tread paths by moonlight that others fear to speak of during day. I have talked to Gods, loved women, and written songs that make the minstrels weep.",
"9781473211896",
authors[0],
[genres[0]]
),
bookCreate(1,
bookCreate(
1,
"The Wise Man's Fear (The Kingkiller Chronicle, #2)",
"Picking up the tale of Kvothe Kingkiller once again, we follow him into exile, into political intrigue, courtship, adventure, love and magic... and further along the path that has turned Kvothe, the mightiest magician of his age, a legend in his own time, into Kote, the unassuming pub landlord.",
"9788401352836",
authors[0],
[genres[0]]
),
bookCreate(2,
bookCreate(
2,
"The Slow Regard of Silent Things (Kingkiller Chronicle)",
"Deep below the University, there is a dark place. Few people know of it: a broken web of ancient passageways and abandoned rooms. A young woman lives there, tucked among the sprawling tunnels of the Underthing, snug in the heart of this forgotten place.",
"9780756411336",
authors[0],
[genres[0]]
),
bookCreate(3,
bookCreate(
3,
"Apes and Angels",
"Humankind headed out to the stars not for conquest, nor exploration, nor even for curiosity. Humans went to the stars in a desperate crusade to save intelligent life wherever they found it. A wave of death is spreading through the Milky Way galaxy, an expanding sphere of lethal gamma ...",
"9780765379528",
authors[1],
[genres[1]]
),
bookCreate(4,
bookCreate(
4,
"Death Wave",
"In Ben Bova's previous novel New Earth, Jordan Kell led the first human mission beyond the solar system. They discovered the ruins of an ancient alien civilization. But one alien AI survived, and it revealed to Jordan Kell that an explosion in the black hole at the heart of the Milky Way galaxy has created a wave of deadly radiation, expanding out from the core toward Earth. Unless the human race acts to save itself, all life on Earth will be wiped out...",
"9780765379504",
authors[1],
[genres[1]]
),
bookCreate(5,
bookCreate(
5,
"Test Book 1",
"Summary of test book 1",
"ISBN111111",
authors[4],
[genres[0], genres[1]]
),
bookCreate(6,
bookCreate(
6,
"Test Book 2",
"Summary of test book 2",
"ISBN222222",
Expand All @@ -165,40 +172,52 @@ async function createBooks() {
async function createBookInstances() {
console.log("Adding authors");
await Promise.all([
bookInstanceCreate(0, books[0], "London Gollancz, 2014.", false, "Available"),
bookInstanceCreate(
0,
books[0],
"London Gollancz, 2014.",
false,
"Available"
),
bookInstanceCreate(1, books[1], " Gollancz, 2011.", false, "Loaned"),
bookInstanceCreate(2, books[2], " Gollancz, 2015.", false, false),
bookInstanceCreate(3,
bookInstanceCreate(
3,
books[3],
"New York Tom Doherty Associates, 2016.",
false,
"Available"
),
bookInstanceCreate(4,
bookInstanceCreate(
4,
books[3],
"New York Tom Doherty Associates, 2016.",
false,
"Available"
),
bookInstanceCreate(5,
bookInstanceCreate(
5,
books[3],
"New York Tom Doherty Associates, 2016.",
false,
"Available"
),
bookInstanceCreate(6,
bookInstanceCreate(
6,
books[4],
"New York, NY Tom Doherty Associates, LLC, 2015.",
false,
"Available"
),
bookInstanceCreate(7,
bookInstanceCreate(
7,
books[4],
"New York, NY Tom Doherty Associates, LLC, 2015.",
false,
"Maintenance"
),
bookInstanceCreate(8,
bookInstanceCreate(
8,
books[4],
"New York, NY Tom Doherty Associates, LLC, 2015.",
false,
Expand Down

0 comments on commit 2f692d0

Please sign in to comment.