diff --git a/Week3/EX3-injection.js b/Week3/EX3-injection.js new file mode 100644 index 000000000..4d58e59a4 --- /dev/null +++ b/Week3/EX3-injection.js @@ -0,0 +1,27 @@ +const client = require('pg'); + +const client = new Client({ +host: "localhost", +user: "hyfuser", +password: "hyfpass", +database: "world", +port: 5432, +}); + +client.connect(); +async function getPopulation(countryTable, name, code) { +const sql = ` +SELECT population +FROM ${countryTable} +WHERE name = $1 AND code = $2 +`; +const values = [name, code]; + +const result = await client.query(sql, values); + +if (!result || result.rows.length === 0) { +throw new Error('Not found'); +} + +return result.rows[0].population; +} \ No newline at end of file diff --git a/Week3/Ex1-Normalization.sql b/Week3/Ex1-Normalization.sql new file mode 100644 index 000000000..11cdadd80 --- /dev/null +++ b/Week3/Ex1-Normalization.sql @@ -0,0 +1,45 @@ +-- 3NF Normalized Schema + + +CREATE TABLE members ( + member_id INT PRIMARY KEY, + member_name VARCHAR(100) NOT NULL, + member_address VARCHAR(200) NOT NULL +); + +CREATE TABLE venues ( + venue_code VARCHAR(10) PRIMARY KEY, + venue_description VARCHAR(200) NOT NULL +); + + +CREATE TABLE dinners ( + dinner_id VARCHAR(20) PRIMARY KEY, + dinner_date DATE NOT NULL, + venue_code VARCHAR(10) NOT NULL, + FOREIGN KEY (venue_code) REFERENCES venues(venue_code) +); + + +CREATE TABLE food ( + food_code VARCHAR(10) PRIMARY KEY, + food_description VARCHAR(100) NOT NULL +); + + +CREATE TABLE dinner_food ( + dinner_id VARCHAR(20), + food_code VARCHAR(10), + PRIMARY KEY (dinner_id, food_code), + FOREIGN KEY (dinner_id) REFERENCES dinners(dinner_id), + FOREIGN KEY (food_code) REFERENCES food(food_code) +); + + +CREATE TABLE member_dinner ( + member_id INT, + dinner_id VARCHAR(20), + PRIMARY KEY (member_id, dinner_id), + FOREIGN KEY (member_id) REFERENCES members(member_id), + FOREIGN KEY (dinner_id) REFERENCES dinners(dinner_id) +); diff --git a/Week3/Ex1_Normalization-screenshot.png b/Week3/Ex1_Normalization-screenshot.png new file mode 100644 index 000000000..bee00fcfd Binary files /dev/null and b/Week3/Ex1_Normalization-screenshot.png differ diff --git a/Week3/Ex2-Transactions/Screenshot 2025-12-23 210055.png b/Week3/Ex2-Transactions/Screenshot 2025-12-23 210055.png new file mode 100644 index 000000000..70a69974e Binary files /dev/null and b/Week3/Ex2-Transactions/Screenshot 2025-12-23 210055.png differ diff --git a/Week3/Ex2-Transactions/account-chang.png b/Week3/Ex2-Transactions/account-chang.png new file mode 100644 index 000000000..431622644 Binary files /dev/null and b/Week3/Ex2-Transactions/account-chang.png differ diff --git a/Week3/Ex2-Transactions/balance-screenshot.png b/Week3/Ex2-Transactions/balance-screenshot.png new file mode 100644 index 000000000..a1a86a3c2 Binary files /dev/null and b/Week3/Ex2-Transactions/balance-screenshot.png differ diff --git a/Week3/Ex2-Transactions/create-tables.js b/Week3/Ex2-Transactions/create-tables.js new file mode 100644 index 000000000..05b4634d4 --- /dev/null +++ b/Week3/Ex2-Transactions/create-tables.js @@ -0,0 +1,31 @@ +import client from "./database.js"; + +async function createTables() { +await client.connect(); + +try { +await client.query(` + CREATE TABLE IF NOT EXISTS account ( + account_number INT PRIMARY KEY, + balance NUMERIC(12,2) NOT NULL + ); + + CREATE TABLE IF NOT EXISTS account_changes ( + change_number SERIAL PRIMARY KEY, + account_number INT NOT NULL, + amount NUMERIC(12,2) NOT NULL, + changed_date TIMESTAMP DEFAULT NOW(), + remark TEXT, + FOREIGN KEY (account_number) REFERENCES account(account_number) + ); +`); + +console.log("Tables created successfully"); +} catch (err) { +console.error("Error creating tables:", err); +} finally { +await client.end(); +} +} + +createTables(); diff --git a/Week3/Ex2-Transactions/database.js b/Week3/Ex2-Transactions/database.js new file mode 100644 index 000000000..935391895 --- /dev/null +++ b/Week3/Ex2-Transactions/database.js @@ -0,0 +1,11 @@ +import pg from "pg"; + +const client = new pg.Client({ +host: "localhost", +port: 5432, +user: "hyfuser", +password: "hyfpassword", +database: "bankdb", +}); + +export default client; diff --git a/Week3/Ex2-Transactions/insert-values.js b/Week3/Ex2-Transactions/insert-values.js new file mode 100644 index 000000000..15205a303 --- /dev/null +++ b/Week3/Ex2-Transactions/insert-values.js @@ -0,0 +1,24 @@ +import client from "./database.js"; + +async function insertValues() { +await client.connect(); + +try { +await client.query(` + INSERT INTO account (account_number, balance) + VALUES + (101, 5000), + (102, 3000) + ON CONFLICT (account_number) DO NOTHING; +`); + +console.log("Sample accounts inserted"); + +} catch (err) { +console.error("Error inserting values:", err); +} finally { +await client.end(); +} +} + +insertValues(); diff --git a/Week3/Ex2-Transactions/transaction.js b/Week3/Ex2-Transactions/transaction.js new file mode 100644 index 000000000..2854b8b11 --- /dev/null +++ b/Week3/Ex2-Transactions/transaction.js @@ -0,0 +1,49 @@ +import client from "./database.js"; + +async function doTransaction() { +await client.connect(); + +try { +await client.query("BEGIN"); + +const amount = 1000; +const fromAcc = 101; +const toAcc = 102; + +// 1. Subtract from account 101 +await client.query( + `UPDATE account SET balance = balance - $1 WHERE account_number = $2`, + [amount, fromAcc] +); + +await client.query( + `INSERT INTO account_changes (account_number, amount, remark) + VALUES ($1, $2, 'Transfer to 102')`, + [fromAcc, -amount] +); + +// 2. Add to account 102 +await client.query( + `UPDATE account SET balance = balance + $1 WHERE account_number = $2`, + [amount, toAcc] +); + +await client.query( + `INSERT INTO account_changes (account_number, amount, remark) + VALUES ($1, $2, 'Transfer from 101')`, + [toAcc, amount] +); + +// If everything is OK → commit +await client.query("COMMIT"); +console.log("Transaction completed successfully"); + +} catch (err) { +console.error("Transaction failed:", err); +await client.query("ROLLBACK"); +} finally { +await client.end(); +} +} + +doTransaction(); diff --git a/Week3/Ex3-injection-screenshot.png b/Week3/Ex3-injection-screenshot.png new file mode 100644 index 000000000..37642301a Binary files /dev/null and b/Week3/Ex3-injection-screenshot.png differ diff --git a/Week3/homework/mongodb/.env.example b/Week3/homework/mongodb/.env.example index f7bdfd393..05f2a521d 100644 --- a/Week3/homework/mongodb/.env.example +++ b/Week3/homework/mongodb/.env.example @@ -4,4 +4,4 @@ # - look up how to connect to your database in atlas, there is a nice `connect` button that will help you out # - fill in the link to your new database. Make sure the database is `databaseWeek3`! -MONGODB_URL=mongodb+srv://:@/databaseWeek3?retryWrites=true&w=majority \ No newline at end of file +MONGODB_URL=mongodb+srv://asaadeddin87_db_user:@/databaseWeek3 \ No newline at end of file diff --git a/Week3/homework/mongodb/.gitignore b/Week3/homework/mongodb/.gitignore new file mode 100644 index 000000000..4290ff56a --- /dev/null +++ b/Week3/homework/mongodb/.gitignore @@ -0,0 +1,2 @@ +.env +node_modules/ \ No newline at end of file diff --git a/Week3/homework/mongodb/Exe4-Screenshot .png b/Week3/homework/mongodb/Exe4-Screenshot .png new file mode 100644 index 000000000..b8da5de54 Binary files /dev/null and b/Week3/homework/mongodb/Exe4-Screenshot .png differ diff --git a/Week3/homework/mongodb/index.js b/Week3/homework/mongodb/index.js index 41ee8b618..57d69a045 100644 --- a/Week3/homework/mongodb/index.js +++ b/Week3/homework/mongodb/index.js @@ -1,104 +1,81 @@ +require('dotenv').config(); const { MongoClient, ServerApiVersion } = require("mongodb"); - const { seedDatabase } = require("./seedDatabase.js"); async function createEpisodeExercise(client) { - /** - * We forgot to add the last episode of season 9. It has this information: - * - * episode: S09E13 - * title: MOUNTAIN HIDE-AWAY - * elements: ["CIRRUS", "CLOUDS", "CONIFER", "DECIDIOUS", "GRASS", "MOUNTAIN", "MOUNTAINS", "RIVER", "SNOWY_MOUNTAIN", "TREE", "TREES"] - */ + const collection = client.db("databaseWeek3").collection("bob_ross_episodes"); + + const newEpisode = { + episode: "S09E13", + title: "MOUNTAIN HIDE-AWAY", + elements: ["CIRRUS", "CLOUDS", "CONIFER", "DECIDUOUS", "GRASS", "MOUNTAIN", "MOUNTAINS", "RIVER", "SNOWY_MOUNTAIN", "TREE", "TREES"] + }; - // Write code that will add this to the collection! + const result = await collection.insertOne(newEpisode); console.log( - `Created season 9 episode 13 and the document got the id ${"TODO: fill in variable here"}` + `Created season 9 episode 13 and the document got the id ${result.insertedId}` ); } async function findEpisodesExercises(client) { - /** - * Complete the following exercises. - * The comments indicate what to do and what the result should be! - */ - - // Find the title of episode 2 in season 2 [Should be: WINTER SUN] - - console.log( - `The title of episode 2 in season 2 is ${"TODO: fill in variable here"}` - ); + const collection = client.db("databaseWeek3").collection("bob_ross_episodes"); - // Find the season and episode number of the episode called "BLACK RIVER" [Should be: S02E06] + // Title of episode 2 in season 2 + const ep2s2 = await collection.findOne({ episode: "S02E02" }); + console.log(`The title of episode 2 in season 2 is ${ep2s2.title}`); - console.log( - `The season and episode number of the "BLACK RIVER" episode is ${"TODO: fill in variable here"}` - ); - - // Find all of the episode titles where Bob Ross painted a CLIFF [Should be: NIGHT LIGHT, EVENING SEASCAPE, SURF'S UP, CLIFFSIDE, BY THE SEA, DEEP WILDERNESS HOME, CRIMSON TIDE, GRACEFUL WATERFALL] - - console.log( - `The episodes that Bob Ross painted a CLIFF are ${"TODO: fill in variable here"}` - ); + // Season and episode of "BLACK RIVER" + const blackRiver = await collection.findOne({ title: "BLACK RIVER" }); + console.log(`The season and episode number of the "BLACK RIVER" episode is ${blackRiver.episode}`); - // Find all of the episode titles where Bob Ross painted a CLIFF and a LIGHTHOUSE [Should be: NIGHT LIGHT] + // Episodes with CLIFF + const cliffEpisodes = await collection.find({ elements: "CLIFF" }).toArray(); + console.log(`The episodes that Bob Ross painted a CLIFF are ${cliffEpisodes.map(e => e.title).join(", ")}`); - console.log( - `The episodes that Bob Ross painted a CLIFF and a LIGHTHOUSE are ${"TODO: fill in variable here"}` - ); + // Episodes with CLIFF and LIGHTHOUSE + const cliffLighthouse = await collection.find({ elements: { $all: ["CLIFF", "LIGHTHOUSE"] } }).toArray(); + console.log(`The episodes that Bob Ross painted a CLIFF and a LIGHTHOUSE are ${cliffLighthouse.map(e => e.title).join(", ")}`); } async function updateEpisodeExercises(client) { - /** - * There are some problems in the initial data that was filled in. - * Let's use update functions to update this information. - * - * Note: do NOT change the data.json file - */ + const collection = client.db("databaseWeek3").collection("bob_ross_episodes"); - // Episode 13 in season 30 should be called BLUE RIDGE FALLS, yet it is called BLUE RIDGE FALLERS now. Fix that - - console.log( - `Ran a command to update episode 13 in season 30 and it updated ${"TODO: fill in variable here"} episodes` + // Fix season 30 episode 13 title + const updateTitle = await collection.updateOne( + { episode: "S30E13" }, + { $set: { title: "BLUE RIDGE FALLS" } } ); + console.log(`Ran a command to update episode 13 in season 30 and it updated ${updateTitle.modifiedCount} episodes`); - // Unfortunately we made a mistake in the arrays and the element type called 'BUSHES' should actually be 'BUSH' as sometimes only one bush was painted. - // Update all of the documents in the collection that have `BUSHES` in the elements array to now have `BUSH` - // It should update 120 episodes! - - console.log( - `Ran a command to update all the BUSHES to BUSH and it updated ${"TODO: fill in variable here"} episodes` + // Replace BUSHES with BUSH + const updateBushes = await collection.updateMany( + { elements: "BUSHES" }, + { $set: { "elements.$": "BUSH" } } ); + console.log(`Ran a command to update all the BUSHES to BUSH and it updated ${updateBushes.modifiedCount} episodes`); } async function deleteEpisodeExercise(client) { - /** - * It seems an errand episode has gotten into our data. - * This is episode 14 in season 31. Please remove it and verify that it has been removed! - */ + const collection = client.db("databaseWeek3").collection("bob_ross_episodes"); - console.log( - `Ran a command to delete episode and it deleted ${"TODO: fill in variable here"} episodes` - ); + const result = await collection.deleteOne({ episode: "S31E14" }); + console.log(`Ran a command to delete episode and it deleted ${result.deletedCount} episodes`); } async function main() { - if (process.env.MONGODB_URL == null) { - throw Error( - `You did not set up the environment variables correctly. Did you create a '.env' file and add a package to create it?` - ); + if (!process.env.MONGODB_URL) { + throw new Error("Please set MONGODB_URL in your .env file"); } + const client = new MongoClient(process.env.MONGODB_URL, { - useNewUrlParser: true, - useUnifiedTopology: true, - serverApi: ServerApiVersion.v1, + serverApi: ServerApiVersion.v1 }); try { await client.connect(); - // Seed our database + // Seed database await seedDatabase(client); // CREATE @@ -112,11 +89,11 @@ async function main() { // DELETE await deleteEpisodeExercise(client); + } catch (err) { console.error(err); } finally { - // Always close the connection at the end - client.close(); + await client.close(); } } diff --git a/Week3/homework/mongodb/package-lock.json b/Week3/homework/mongodb/package-lock.json new file mode 100644 index 000000000..7f0baa51c --- /dev/null +++ b/Week3/homework/mongodb/package-lock.json @@ -0,0 +1,333 @@ +{ + "name": "week3", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "week3", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "dotenv": "^17.2.3", + "mangodb": "^1.0.0", + "mongodb": "^7.0.0", + "pg": "^8.16.3" + } + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.3.2.tgz", + "integrity": "sha512-QgA5AySqB27cGTXBFmnpifAi7HxoGUeezwo6p9dI03MuDB6Pp33zgclqVb6oVK3j6I9Vesg0+oojW2XxB59SGg==", + "license": "MIT", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", + "license": "MIT" + }, + "node_modules/@types/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/bson": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.0.0.tgz", + "integrity": "sha512-Kwc6Wh4lQ5OmkqqKhYGKIuELXl+EPYSCObVE6bWsp1T/cGkOCBN0I8wF/T44BiuhHyNi1mmKVPXk60d41xZ7kw==", + "license": "Apache-2.0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/dotenv": { + "version": "17.2.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz", + "integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/mangodb": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mangodb/-/mangodb-1.0.0.tgz", + "integrity": "sha512-9spyqiyoF2ePs1GGePNAfGGv24+hvgkJiYkOOR+ZML0VB5aDXONgtd4iUSZ94yRToPx7P8MXI8ZFwyzzF0+TTg==", + "license": "MIT" + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "license": "MIT" + }, + "node_modules/mongodb": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz", + "integrity": "sha512-vG/A5cQrvGGvZm2mTnCSz1LUcbOPl83hfB6bxULKQ8oFZauyox/2xbZOoGNl+64m8VBrETkdGCDBdOsCr3F3jg==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.3.0", + "bson": "^7.0.0", + "mongodb-connection-string-url": "^7.0.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": ">=7.0.0 <7.1.0", + "snappy": "^7.3.2", + "socks": "^2.8.6" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.0.tgz", + "integrity": "sha512-irhhjRVLE20hbkRl4zpAYLnDMM+zIZnp0IDB9akAFFUZp/3XdOfwwddc7y6cNvF2WCEtfTYRwYbIfYa2kVY0og==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^14.1.0" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/pg": { + "version": "8.16.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", + "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.9.1", + "pg-pool": "^3.10.1", + "pg-protocol": "^1.10.3", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.2.7" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz", + "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz", + "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz", + "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz", + "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/Week3/homework/mongodb/package.json b/Week3/homework/mongodb/package.json new file mode 100644 index 000000000..3f4010e64 --- /dev/null +++ b/Week3/homework/mongodb/package.json @@ -0,0 +1,18 @@ +{ + "dependencies": { + "dotenv": "^17.2.3", + "mangodb": "^1.0.0", + "mongodb": "^7.0.0", + "pg": "^8.16.3" + }, + "name": "week3", + "version": "1.0.0", + "description": "These are the topics for week 3:", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/Week3/package-lock.json b/Week3/package-lock.json new file mode 100644 index 000000000..6b3385197 --- /dev/null +++ b/Week3/package-lock.json @@ -0,0 +1,178 @@ +{ + "name": "Week3", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "dotenv": "^17.2.3", + "mangodb": "^1.0.0", + "pg": "^8.16.3" + } + }, + "node_modules/dotenv": { + "version": "17.2.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz", + "integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/mangodb": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mangodb/-/mangodb-1.0.0.tgz", + "integrity": "sha512-9spyqiyoF2ePs1GGePNAfGGv24+hvgkJiYkOOR+ZML0VB5aDXONgtd4iUSZ94yRToPx7P8MXI8ZFwyzzF0+TTg==", + "license": "MIT" + }, + "node_modules/pg": { + "version": "8.16.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", + "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.9.1", + "pg-pool": "^3.10.1", + "pg-protocol": "^1.10.3", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.2.7" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz", + "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz", + "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz", + "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz", + "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/Week3/package.json b/Week3/package.json new file mode 100644 index 000000000..d403121f9 --- /dev/null +++ b/Week3/package.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "dotenv": "^17.2.3", + "mangodb": "^1.0.0", + "pg": "^8.16.3" + } +}