Code Monkey home page Code Monkey logo

typescript-sequelize-example's Introduction

So you want to use types with Sequelize?

How to use Typescript with Sequelize

This repo shows how to use Sequelize v4 with Typescript, including how to set up associations.

You can use tags in this repo to follow along with the accompnaying article, which is found here.

The automated script for generating ModelInstance definitions is found here.

Usage

You can run the web server with yarn install && yarn start. The server is launched on port 3000. You can access paths via your browser, or, by using a HTTP client like Postman.

App Structure

Inside src/app.ts, we launch the server and set up lots of example paths to demonstrate Sequelize+Typescript in action. The model definitions are in src/models/. Some types we define to help us get better type inference across our project when using Sequelize+Typescript are found in src/typings.

Setting up your database

The database connection config passed into Sequelize is stored in src/config/sequelizeConfig.json. It currently connects to a Postgres database on localhost called tutorial, with user postgres and no password. You may wish to change this. You probably will also need to create a database yourself. You don't have to use Postgres; Sequelize is database agnostic.

typescript-sequelize-example's People

Contributors

ahmerb 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.