Created
February 2, 2011 12:32
-
-
Save victusfate/807616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.open("tweets.db", function(error){ | |
| if (error) { | |
| console.log("Error opening database"); | |
| throw error; | |
| } | |
| db.getTweets = function(res){ | |
| console.log("calling get tweets"); | |
| db.execute("select name,message,timestamp from tweets join names on tweets.key = names.key", function(error, rows){ | |
| if (error && error.message.search("no such table: tweets") != -1){ | |
| console.log(error);//throw error; | |
| db.execute("CREATE TABLE tweets (key, message, timestamp)",function(){}); | |
| db.execute("CREATE TABLE names (key, name)",function(){}); | |
| db.getTweets(res); | |
| return; | |
| } | |
| if (!rows || rows.length < 1){ | |
| db.execute("select key,message,timestamp from tweets", function(error, rows){ | |
| for (x in rows){ | |
| row = rows[x]; | |
| row.name = row.key; | |
| //row.name = 'test'; | |
| } | |
| //console.log(rows); | |
| console.log("Calling render tweets from select key"); | |
| http.renderTweets(res, rows); | |
| }); | |
| return | |
| } | |
| //res.end(JSON.stringify(rows)); | |
| console.log("calling render tweets from main function"); | |
| console.log(rows); | |
| http.renderTweets(res, rows); | |
| console.log(rows); | |
| }); | |
| }; | |
| //db.getTweets(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment