0

I work with Node.JS and MySQL with "mysql" package. Is there is a way to define models with class ?? I read a lot and all opinion say i need sequellize for this. In angular i use data model like this:

export class Stage {
    public name: string;
    public consultation: string;
    public approval: string;
    public stageOrder: number;
}

Is there is a way to make it work in nodejs? Thanks

1 Answer 1

1

Yes there is, you need to use sequellize and defined a class in this way:

           const Stage = sequelize.define('stage', {
  name: {
    type: Sequelize.STRING,
    allowNull: false
  },
  consultation: {
    type: Sequelize.STRING
   
  },
 approval: {
    type: Sequelize.STRING
   
  },
 stageOrder: {
    type: Sequelize.INTEGER
   
  }
}, {
  // options
});

You can read the documentation here.

Sign up to request clarification or add additional context in comments.

2 Comments

Sequelize can be install and work with "mysql" package or it replace it?
yes , you can use MySql. If you need more details , take a look at the following linke:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.