Search code examples
node.jsalasql

Delete query in Alasql


i am new to Alasql.

In my nodejs code i have written below piece of code for delete an item. but it is not getting deleted. Any help?

This is my create table query

 sqldb.exec('CREATE TABLE Cores ([node-id], name, [ip-address], [sw-version], longitude, latitude)');

here is the delete queries

sqldb.exec('DELETE FROM Cores WHERE [node-id] =\'%s\'', Id);
sqldb.exec('DELETE FROM Cores WHERE [node-id] = ?', Id);
sqldb.exec('DELETE FROM Cores WHERE [node-id] ='+ Id);

i tried all the above combinations when I return sqldb.exec(query) i am getting 0 and the value is not getting deleted. No error messages are thrown.


Solution

  • I figure we are using util module and I have used below code to format my query then it was able to delete a record.

    var util = require('util');
    sqldb.exec(util.format('DELETE FROM Cores WHERE [node-id] =\'%s\'', coreId));