Skip to content

Commit

Permalink
feat: patch js
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred-Lau committed May 17, 2024
1 parent 04b30dc commit e2da604
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions javascript/sveltekit/src/routes/api/todos/+page.server.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { oceanbaseConnection } from '../../../lib/db/oceanbase';
import { createOceanbaseConnection } from '../../../lib/db/oceanbase';

export async function get() {
let results = await oceanbaseConnection
.query('SELECT * FROM tasks')
.then(function ([rows, fields]) {
console.log(rows);
return rows;
});
let results = await createOceanbaseConnection()
.query('SELECT * FROM tasks')
.then(function ([rows, fields]) {
console.log(rows);
return rows;
});

return {
body: results,
};
return {
body: results,
};
}
export async function post(request) {
console.log(request);
const { text, completed } = request.body;
let newTask = await oceanbaseConnection
.query('INSERT INTO tasks (text, completed) VALUES (?, ?)', [
text,
completed,
])
.then(function ([result]) {
return { id: result.insertId, text: text, completed: completed };
});
return {
body: newTask,
};
console.log(request);
const { text, completed } = request.body;
let newTask = await createOceanbaseConnection()
.query('INSERT INTO tasks (text, completed) VALUES (?, ?)', [
text,
completed,
])
.then(function ([result]) {
return { id: result.insertId, text: text, completed: completed };
});
return {
body: newTask,
};
}

0 comments on commit e2da604

Please sign in to comment.