Coder Social home page Coder Social logo

backend-postgresql-crud-with-knex's Introduction

Backend-PostgreSQL-CRUD-with-Knex

Node, Express, and PostgreSQL: CRUD with Knex Instructions You are a backend developer for a restaurant-finder application called Thinkful Eats, and you've been tasked to query some data about various restaurants in the database. Their backend technology stack is currently in Node.js/Express, PostgreSQL, and Knex. There is currently only one table, restaurants, in the database. It has the following columns:

restaurant_id (primary key) restaurant_name (required string) cuisine (required string) address (required string) To complete this assessment, you will need to complete the tasks described below to get the tests to pass.

Existing files In this lesson, all the required server routes have already set up for you, so you won't have to edit the src/restaurants/restaurants.router.js file. The test suite will automatically set up a test database, then migrate and seed the database with some test data as well. Take some time to understand the content of the existing files.

You will then have to write Knex queries to complete the functions defined inside the src/restaurants/restaurants.service.js and src/restaurants/restaurants.controller.js files.

Tasks In src/restaurants/restaurants.service.js:

Complete the create() function to create a new restaurant in the restaurants table, returning all columns of the newly created restaurant in the result. Complete the destroy() function to delete a restaurant given the restaurant ID. In src/restaurants/restaurants.controller.js:

Update the create() route handler to call the create() method of the service and return a 201 status code along with the newly created restaurant. Validate that the request body only contains the properties restaurant_name, cuisine, and address, and validate that each property has a value. Return a 400 status code if the validation fails. Update the destroy() route handler to call the delete() method of the service, and return a 204 status code upon successful restaurant deletion.

backend-postgresql-crud-with-knex's People

Contributors

holly-ellington avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.