Skip to content

Commit

Permalink
Merge pull request #110 from allenwang2333/delet-todo
Browse files Browse the repository at this point in the history
Delet todo
  • Loading branch information
JackHe313 authored Nov 30, 2022
2 parents 68dea6d + a4bc270 commit da7faec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ app.post('/server_postLike', (req, res) => {
var id = req.body.postID;
db.connectDatabase(() => {
db.likeOrUnlikePost(table, id, count, (postInfo) => {
// TODO: send new like count to front end
if (Object.keys(postInfo).length !== 0) {
res.send([{ "valid": true }, { "message": "successfully posted" }]);
}
Expand All @@ -143,13 +142,14 @@ app.post('/server_postLike', (req, res) => {
});

app.post('/success', (req, res) => {
let table = "scoreboard";
var username = req.body.username;
var userid = req.body.userid;
var score = req.body.score;
var time = req.body.time;
let winGame = [{ "valid": false }];
db.connectDatabase(() => {
db.addUserOrUpdateScoreboard("scoreboard", username, userid, score, time, (scoreInfo) => {
db.addUserOrUpdateScoreboard(table, username, userid, score, time, (scoreInfo) => {
winGame = [{ "valid": true }];
console.log(scoreInfo)
res.send(winGame)
Expand Down
3 changes: 2 additions & 1 deletion sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class QueryDatabase {
}
//console.log("-------- Connected to " + this.filePath + " database --------");
});
callback();
callback(); // callback to the next function, very important for not using async in JS.
}

readTableAll(table, callback) {
Expand Down Expand Up @@ -153,6 +153,7 @@ class QueryDatabase {
}

searchPosts(table, keyword, callback) {
// search for content, title and author, case insensitive
var queryString = `SELECT * FROM ${table} WHERE ` +
`title LIKE "%${keyword}%" ` +
`OR content LIKE "%${keyword}%" ` +
Expand Down

0 comments on commit da7faec

Please sign in to comment.