Insert operation is not inserting data properly
See original GitHub issueHi, I am facing a problem. I have a messenger application. i am sending messages using socket.io. If i type a message slowly and emit it’s working fine. But if i type several message quickly and send it to socket emit the out put is something like this
3048 : asd 3049 : asd 3056 : d 3056 : d 3056 : d 3056 : d 3056 : d 3056 : d 3056 : d 3062 : das 3062 : das 3062 : das 3062 : das 3062 : das 3062 : das 3071 : as 3071 : as 3072 : asd 3072 : asd 3072 : asd 3072 : asd 3072 : asd 3072 : asd 3072 : asd 3072 : asd 3076 : das 3076 : das 3076 : das 3076 : das
code is
await sMM.Im_message_Model.insert(senderId, receiverId, message, fileType, null, receiverType, date, time, date_time);
let fullMessage = await sMM.Im_message_Model.getRecentMessageWithUpdate(receiverId);
console.log(fullMessage.m_id+" : "+fullMessage.message);
Functions:
Im_message_Model.getRecentMessageWithUpdate = async (g_id)=>{
let query="select * from im_message where receiver=? order by m_id DESC LIMIT 1";
let [result,err]=await mysqlCon.execute(query,[g_id]);
if(result.length>0){
let prepareData=result[0];
prepareData.poster="";
if(prepareData.type!="text" && prepareData.type!="update" && prepareData.type!="document"){
prepareData.message= baseUrl+"assets/im/group_"+g_id+"/"+prepareData.message;
}
if(prepareData.type=="document"){
let fileUrl=encodeURIComponent(baseUrl + "assets/im/group_"+prepareData.receiver+"/"+prepareData.message)+"&fn="+encodeURIComponent(prepareData.fileName);
prepareData.message=baseUrl+"download?f="+fileUrl;
}
if(prepareData.type=="video"){
prepareData.poster=baseUrl+"assets/img/poster.jpg";
}
return prepareData;
}
};
Im_message_Model.insert= async (u_id,g_id,message,type,fileName,receiver_type,date,time,date_time)=>{
let query="INSERT INTO im_message (sender,receiver,message,type,fileName,receiver_type,date,time,date_time) VALUES (?,?,?,?,?,?,?,?,?)";
await mysqlCon.execute(query,[u_id,g_id,message,type,fileName,receiver_type,date,time,date_time]);
};
m_id is unique and auto increment primary key.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
insert query is giving no error but is not inserting in the database
One thing to check is to see if the table has a trigger. An instead of trigger could be overruling your insert. The...
Read more >INSERT Operations That Are Not Valid - Teradata Database
INSERT Operations That Are Not Valid An INSERT operation causes an error or failure message to be returned if any of the following...
Read more >Methods to Insert Data into SQL Server
Insert Data SQL Server with OUTPUT INSERTED ... WHERE account_type = 'LIVE';. SELECT * FROM #account_ids;. DROP TABLE #account_ids;. The results ...
Read more >4. Inserting, Updating, Deleting - SQL Cookbook [Book] - O'Reilly
Simply follow the INSERT statement with a query that returns the desired rows. If you want to copy all rows from the source...
Read more >Bulk Insert Task - SQL Server Integration Services (SSIS)
If the text file is located on the same computer as the SQL Server database into which data is inserted, the copy operation...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, This is my db picture.
I am using pool.
mysql2.createPool(database.dbSettings());
do i need to release the pool connection after every query execution? New to node js. Don’t know how to enable debug option on connection. Can you help me in this ?
log.txt