Skip to content

Conversation

@maxbmaapc
Copy link

No description provided.

…L queries

feat(README.md): add task 1 to README.md to list rooms with a rate of more than 100.00

feat(README.md): add task 2 to README.md to list reservations with a checkin date this month and for more than three nights

feat(README.md): add task 3 to README.md to list customers from cities that begin with the letter 'M'

feat(README.md): add task 4 to README.md to create a new room type PENTHOUSE with a default rate of £185.00

feat(README.md): add task 5 to README.md to add new rooms 501 and 502 as room type PENTHOUSE with the default rate

feat(README.md): add task 6 to README.md to add a new room 503 as a PREMIER PLUS type with a room rate of 143.00 to reflect improved views over the city
This commit adds SQL queries to complete the tasks for setting up and querying an ecommerce database. The queries include retrieving customers' names and addresses who live in the United States, retrieving customers in ascending name sequence, retrieving products whose name contains the word 'socks', retrieving products that cost more than 100, retrieving the 5 most expensive products, retrieving products with their corresponding suppliers, retrieving products sold by suppliers based in the United Kingdom, retrieving orders from a specific customer ID, retrieving orders from a customer named 'Hope Crosby', retrieving products in a specific order, retrieving products with their supplier for all orders of all customers, retrieving customers who bought a product from a supplier based in China, and listing all orders with customer name, order reference, order date, and order total amount in descending order of total.
This commit adds SQL queries to complete the tasks for setting up and querying an ecommerce database. The queries include retrieving customers' names and addresses who live in the United States, retrieving customers in ascending name sequence, retrieving products whose name contains the word 'socks', retrieving products that cost more than 100, retrieving the 5 most expensive products, retrieving products with their corresponding suppliers, retrieving products sold by suppliers based in the United Kingdom, retrieving orders from a specific customer ID, retrieving orders from a customer named 'Hope Crosby', retrieving products in a specific order, retrieving products with their supplier for all orders of all customers, retrieving customers who bought a product from a supplier based in China, and listing all orders with customer name, order reference, order date, and order total amount in descending order of total.
This commit adds SQL queries to complete the tasks for setting up and querying an ecommerce database. The queries include retrieving customers' names and addresses who live in the United States, retrieving customers in ascending name sequence, retrieving products whose name contains the word 'socks', retrieving products that cost more than 100 showing product id, name, unit price, and supplier id, retrieving the 5 most expensive products, retrieving all products with their corresponding suppliers, retrieving all products sold by suppliers based in the United Kingdom, retrieving all orders, including order items, from customer ID 1, retrieving all orders, including order items, from customer named 'Hope Crosby', retrieving all the products in the order 'ORD006', retrieving all the products with their supplier for all orders of all customers, retrieving the names of all customers who bought a product from a supplier based in China, and listing all orders giving customer name, order reference, order date, and order total amount in descending order of total.
…tel management system

feat(3-api): add .gitignore file to ignore node_modules directory
feat(3-api): add db.js file to establish connection to PostgreSQL database
feat(3-api): add package.json file with necessary dependencies and start script
feat(3-api): add routes.js file with routes for /customers, /suppliers, and /products endpoints
feat(3-api): add server.js file to start the Express server on a specified port
…ry parameter 'name'

The changes in this commit add support for filtering products by name in the '/products' endpoint. The query parameter 'name' is used to specify the name pattern to filter by. The query pattern is obtained from the 'name' query parameter in the request. The SQL query is modified to include a WHERE clause that filters the products based on the product name using the ILIKE operator. The query pattern is passed as a parameter to the query function to prevent SQL injection.
…g in requests

feat(routes.js): add GET /customers/:cid endpoint to retrieve a specific customer by id
feat(routes.js): add POST /customers endpoint to create a new customer
feat(routes.js): add GET /products endpoint to retrieve products with optional name filter
feat(routes.js): add POST /products endpoint to create a new product
chore(server.js): add body-parser middleware to parse JSON in requests
feat(routes.js): add new route to insert product availability information
…s-controllers

- Add customers-controllers.js file to handle customer-related operations
- Add getAllCustomers function to retrieve all customers from the database
- Add getCustomerById function to retrieve a specific customer by ID from the database
- Add addCustomer function to add a new customer to the database

- Add orders-controllers.js file to handle order-related operations
- Add addOrderByCustId function to add a new order for a specific customer to the database
- Add deleteOrder function to delete an order from the database

- Add products-controllers.js file to handle product-related operations
- Add getAllProducts function to retrieve all products from the database
- Add addProduct function to add a new product to the database

- Update routes.js file to use the newly added controllers
- Update the /customers route to use the getAllCustomers function
- Update the /customers/:cid route to use the getCustomerById function
- Update the /customers route to use the addCustomer function
- Update the /products route to use the getAllProducts function
- Update the /products route to use the addProduct function
- Update the /products/:cid/orders route to use the addOrderByCustId function
- Update the /orders/:oid route to use the deleteOrder function
…le adding product availability to the database

feat(routes.js): add route to handle adding product availability using the addProductAvailability function
…letion of customers

The deleteCustomer function in the customers-controllers module is added to handle the deletion of customers. It takes the customer ID as a parameter and checks if the customer has any active orders. If there are active orders, it returns a 400 status with an error message. If there are no active orders, it deletes the customer from the database and returns a 201 status with a success message.

feat(orders-controllers): add getOrdersByCustId function to retrieve orders by customer ID

The getOrdersByCustId function in the orders-controllers module is added to retrieve orders based on the customer ID. It takes the customer ID as a parameter and queries the database to fetch the orders along with relevant information such as order date, order reference, product name, quantity, unit price, and supplier name. It returns the fetched orders as a JSON response with a 200 status.

feat(routes): add deleteCustomer route and getOrdersByCustId route

The deleteCustomer route is added to the routes module to handle the deletion of customers. It is a DELETE request that takes the customer ID as a parameter and calls the deleteCustomer function from the customers-controllers module.

The getOrdersByCustId route is added to the routes module to retrieve orders by customer ID. It is a GET request that takes the customer ID as a parameter and calls the getOrdersByCustId function from the orders-controllers module.

The existing /suppliers route is also moved to the appropriate location in the routes module. It is a GET request that fetches all the suppliers from the database and returns them as a JSON response with a 200 status.
… updating customer information

feat(routes.js): add PUT route for updating customer information
fix(db.js): use environment variables for database configuration to improve security and flexibility
feat(package.json): add dotenv as a dev dependency to load environment variables from .env file
feat(server.js): add dotenv configuration to load environment variables from .env file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant