Implement a forum data model in JavaScript

Building a JavaScript data model for a forum using TypeScript and TypeORM

We already know about our models and their associations. In this episode, we are going to create a data layer using TypeScript and Node

We already have a project where we have set up TypeScript. To handle our models layer we will use [TypeORM](http://typeorm.io/, which is an ORM that can be used in Node, React and other platforms.

By default, TypeORM places all the entities in a folder called entity.

To create each entity, we will first create a test for the entity, before implementing the entity itself.

To handle the test database, we have used and changed a bit the file that TypeORM uses for testing the database. In this file, we open the connection with the test database and we close it .We also clean the database before each test.

Here is our connection method for the tests. We have environment variables for PGUSER, PGPASSWORD and DATABASE_TEST_NAME

 const connection = await createConnection({ type: 'postgres', host: 'localhost', port: 5432, username:...
Previous - free

Introduction to the forum Data Model

login to comment
  1. Comments for Implement a forum data model in JavaScript