Commit 05c0dc05 authored by Milan Wikarski's avatar Milan Wikarski

Tests

parent 774ee3a1
node_modules
npm-debug.log
publish.sh
.env
\ No newline at end of file
.env
notes.txt
\ No newline at end of file
......@@ -9,6 +9,21 @@ const db = new DB({
password: process.env.DB_PASS
});
const createTable = async () => {
const query = db.query(`
CREATE TABLE IF NOT EXISTS lorem (
"foo" TEXT,
"bar" INTEGER
);
`);
if (await query.execute()) {
console.log('Table created');
} else {
console.log(query.err);
}
};
const select = async () => {
console.log('SELECT');
const select = db.select('lorem').columns('*');
......@@ -25,7 +40,7 @@ const insert = async () => {
console.log('INSERT');
const insert = db.insert('lorem').values([
{ foo: 'Ahoj', bar: 12 },
{ foo: 'Čau', bar: 52 }
{ foo: 'Čau', bar: Math.floor(Math.random() * 100) }
]);
if (await insert.execute()) {
console.log(insert.rows);
......@@ -65,34 +80,37 @@ const update = async () => {
};
(async () => {
// await select();
await createTable();
await insert();
await select();
// await update();
// await select();
const query = db
.tape()
.add(db.begin())
.add(
db
.update('lorem')
.set({ foo: 'Updated Čau', bar: 420 })
.where({ id: 4 })
)
.add(
db.insert('lorem').values([
{ foo: 'Ahoj', bar: 12 },
{ foo: 'Čau', bar: 52 }
])
)
.add(db.select('lorem').columns('*'))
.add(db.commit())
.build();
// const query = db
// .tape()
// .add(db.begin())
// .add(
// db
// .update('lorem')
// .set({ foo: 'Updated Čau', bar: 420 })
// .where({ id: 4 })
// )
// .add(
// db.insert('lorem').values([
// { foo: 'Ahoj', bar: 12 },
// { foo: 'Čau', bar: 52 }
// ])
// )
// .add(db.select('lorem').columns('*'))
// .add(db.commit())
// .build();
if (await query.execute()) {
console.log(query.response);
} else {
console.log(query.err);
}
// if (await query.execute()) {
// console.log(query.response);
// } else {
// console.log(query.err);
// }
process.exit();
})();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment