Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store html values through sequelize ORM in nodeJS application?

I am working on one NodeJs application with NodeJS, Sequelize ORM and mysql2 database.

I am creating a model xyz with one field called "text" which should hold HTML values from frontend as its getting values from a text editor in frontend with bold or italic functionalities among many.

What datatype should I assign to this field "text" in Sequelize as I am lost and I searched but could not find.

I think we cannot store that in String.

Cany anyone suggest ?

like image 861
arjun sah Avatar asked Nov 09 '25 02:11

arjun sah


1 Answers

LONGTEXT is probably excessive -- it allows data sizes up to 4GB.

MEDIUMTEXT allows 16MB.

TEXT allows 64KB.

TINYTEXT allows only 255 characters.

Very few HTML documents are going to be 64KB in size, so a TEXT ought to be suitable for you. If you really want to be safe, go for a MEDIUMTEXT.

Use TEXT datatype for sequelize

like image 102
slideshowp2 Avatar answered Nov 10 '25 20:11

slideshowp2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!