Skip to content

Commit

Permalink
update tutorial for more info on sequelize
Browse files Browse the repository at this point in the history
  • Loading branch information
sord-dev committed Aug 5, 2023
1 parent 16f3c8d commit 5d7df61
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,40 @@ module.exports = router;

Define data models for teams, members, and tickets (`teamModel.js`, `memberModel.js`, `ticketModel.js`) using any storage technology (e.g., a database or in-memory store).

In our case, this is sequelize for a good ORM for postgres and other SQL databases.

```javascript

const { DataTypes } = require('sequelize');
const sequelize = require('../database/sequelize'); // Import your Sequelize instance
const User = require('./UserModel');

const { v4: uuidv4 } = require('uuid');

const Team = sequelize.define('Team', {
id: {
type: DataTypes.STRING,
primaryKey: true,
defaultValue: () => uuidv4() // Create a long unique Id for each team
},
team_name: {
type: DataTypes.STRING,
allowNull: false
},
backlog: {
type: DataTypes.ARRAY(DataTypes.INTEGER), // Assuming backlog contains ticket IDs
defaultValue: [] // Initialize with an empty array
}
});

// Define associations
Team.hasMany(User, { foreignKey: 'team_id', as: 'members' });

module.exports = Team;


```

## App Setup (`app.js`)

Set up your Express application, configure routes, and start the server.
Expand Down

0 comments on commit 5d7df61

Please sign in to comment.