What is used in Nodejs - Sequelize for removing spaces when insert in DB using

ivva

I've used Trim() method to remove spaces from data before insert in DB. I'm using Nodejs and Sequelize. But is there something that is used to do that and for example if I have array, to pass this array, not to loop through all elements to strip spaces? Thanks.

Robert I

Create a mysql trigger that will trim your field on insert

Create them for each of the fields you want trimmed.

I verified this is working on mysql workbench.

Create a mysql trigger that will trim your field on insert

Create them for each of the fields you want trimmed. Example:

I verified this is working on mysql workbench.

Source : Automatically trimming CHAR data on insert into VARCHAR column

Code:

DROP TABLE IF EXISTS tmp; CREATE TABLE tmp ('txt' varchar(50)); DROP TRIGGER IF EXISTS insert_tmp; CREATE TRIGGER insert_tmp BEFORE INSERT ON tmp FOR EACH ROW SET NEW.txt=TRIM(NEW.txt); INSERT INTO tmp VALUES (" abc "), ("efg "); SELECT txt, LENGTH(txt) FROM tmp;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Loop with SQL insert not removing spaces

insert a new record in nodejs using sequelize POST method

How to trim spaces when using a bulk insert?

What happens when removing an object used by a ngRepeat in AngularJS?

Problems with "includes" using Sequelize when a composite foreign key is used

Using Trigger to update database when insert is used

Wordpress - db_insert_error when using insert_post

Insert datas into mysql(Sequelize) using javascript(NodeJS) based on radio button value

Error: db.sequelize.define is not a function in NodeJS

How to keep spaces when removing duplicates with for loop?

how to get the last insert id from a table in DB2 using nodejs and ibm_db package

how to insert a row in table , mysql using bash - when $ is used?

Removing special characters using Ruby, but not spaces

R - removing white spaces using the format() function

Removing Extra spaces in Python using a variable in 'for' Loop

Removing spaces from String using another string

Removing symbols and spaces in strings without using if statements?

Default getters not returning values unless `getDataValue()` is used when using TypeScript in Sequelize

sequelize Bulk insert fails when seeding

What are the default cookies used by NodeJS?

Error when install nodejs with sequelize on centos

Sequelize - How to insert csv data into multiple tables in mysql using sequelize

How insert bulk upload in postgresql using Sequelize?

Sequelize: Using truncate and insert within same transaction

Wordpress is removing 'data' attribute from base64 encoded image when using wp_insert_post

Sequelize for NodeJS and hasMany using UUID error

Using Sequelize with NodeJS and findByPk return pending

how to update Database using hooks/sequelize in nodejs

Group by in Sequelize when using a function