Working with NodeJS , until now, created new rows when a user was not found, and did it in the following way:
const sqlite = require('sqlite');
sqlite.open('points.sqlite').then(() => {
sqlite.get('SELECT * FROM users WHERE ID = ${user}')
.then(rows => {
if (!rows) {
sqlite.run('INSERT INTO users (ID) VALUES (?)', ['${user}'])
.then(() => {
sqlite.get('SELECT * FROM users WHERE ID = ${user}')
.then((row) => {
if (!row) return;
client.scores.set(row.ID, row);
}).catch(console.log);
});
}
}).catch(console.log);
});
However, now I want, with another database, called lpoints.sqlite
, to create a new table with the following fields:
CREATE TABLE 'IDGUILD' (
'IDUSER' TEXT NOT NULL UNIQUE,
'SCORE' INTEGER,
PRIMARY KEY('IDUSER')
);
In which, IDGUILD
would be the variable ID of the guild (string of 18 characters).
How can I create new tables?