Skip to content

neondatabase-labs/guide-neon-sequelize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Running Neon database migrations using Sequelize

This application is a simple typescript API using the Sequelize ORM, Neon and Express.js. It returns a list of authors and books written by them. This project uses Sequelize to generate and run database migrations.

To build this project from scratch, check out the guide in Neon's documentation.

Set up locally

You will need the following:

  • A Neon account and a project
  • Node.js and npm
  1. Clone this repository.
git clone https://github.com/neondatabase/guide-neon-sequelize
  1. Navigate to the project directory and install the dependencies.
cd guide-neon-sequelize
npm install
  1. Create a .env file in the root of the project and add the following environment variables:
DATABASE_URL=
  1. Run the migrations using Sequelize.
npx sequelize db:migrate
  1. Add some entries to the database by running the seed script.
node seed.js
  1. Start the server.
node index.js
  1. Visit http://localhost:3000 in your browser to see the list of authors and books. Or use curl to access the api from the terminal.
# Get a list of authors
curl http://localhost:3000/authors

# Get books by author with id 1
curl http://localhost:3000/books/1

About

Example application for Neon and Sequelize

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published