0

I used alasql and defined created table in node js, like this :

**app.listen(5556,'0.0.0.0', () => {
    alasql("CREATE TABLE  IF NOT EXISTS cart (ID INT AUTOINCREMENT, IDITEM INT,KODEBARANG STRING, NAMA STRING, QTY INT, PRICE INT, SUBTOTAL INT)");
    alasql("CREATE TABLE  IF NOT EXISTS tsuratjalan (ID INT AUTOINCREMENT, IDITEM INT,KODEBARANG STRING, NAMA STRING, QTY INT, PRICE INT, SUBTOTAL INT)");
    alasql("CREATE TABLE  IF NOT EXISTS tpenerimaanbarang (ID INT AUTOINCREMENT, IDITEM INT,KODEBARANG STRING, NAMA STRING, QTY INT, PRICE INT, SUBTOTAL INT)");
    console.log('Server is running at port 5556');
});**

I already defined created table in index.js (server side) but when I tried to insert to this table with ajax on html, it said "Uncaught Table 'tsuratjalan' could not be found".

So table must be defined in one side (server) and only can be inserted from one side also ?

Agoeng Liu
  • 674
  • 3
  • 10
  • 30
  • What's the request look like, the `ajax` request? Is it sending the query to the right database? Do you have access to the database on the server - can you manually use alasql from a terminal and check the tables? – Caleb Jay Jan 15 '19 at 22:57
  • yes from Ajax I try simple query to insert, other modules are okay I did on 1 side, but for this module i tried to do in two side : server and client side, but raised this error. – Agoeng Liu Jan 16 '19 at 02:44
  • There is no database running on the client-side, probably. You probably need to send an AJAX request to your server, which will then turn that request (probably a REST request) into a alasql query. Thing that might help to google: server/client relationship, node REST server, node request handling, building an SQL query from a RESTful request, etc. – Caleb Jay Jan 16 '19 at 18:39

0 Answers0