Skip to content

Commit

Permalink
updraded web api to node 0.1.90 apis
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjjwright committed Apr 12, 2010
1 parent a613f06 commit 348345e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
11 changes: 6 additions & 5 deletions nosqlite.coffee
Expand Up @@ -301,7 +301,7 @@ class NoSQLite
->
# create the temp table
this_flow: this
self.find table, {rowid: 2}, (err, res) ->
self.find table, {rowid: 1}, (err, res) ->
row1: res[0]
delete row1.rowid
create_temp_table_sql: sql.create_temp_table(table, row1)
Expand Down Expand Up @@ -360,7 +360,8 @@ class NoSQLite
statement1.reset()
self.bind_obj statement1, converted_obj
# step once to do the insert
statement1.step ->
statement1.step (err) ->
return callback(err) if err?
migrate_row()
migrate_row()
->
Expand All @@ -384,7 +385,7 @@ class NoSQLite
else
response.writeHead(200, {"Content-Type": "text/plain"})
response.write(JSON.stringify(result))
response.close();
response.end();

# Starts a webserver on the supplied port to serve http requests
# for the instance's associated database.
Expand All @@ -401,7 +402,7 @@ class NoSQLite
if not url.query? or not url.query.method?
response.writeHead(500, {"Content-Type": "text/plain"})
response.write("Must supply method param")
response.close();
response.end();
return
table: url.query.table
# Parse the url to see what the user wants to do
Expand Down Expand Up @@ -429,7 +430,7 @@ class NoSQLite
else
response.writeHead(500, {"Content-Type": "text/plain"})
response.write("Unrecognized method: ${url.query.method}")
response.close();
response.end();
)
server.listen(port, host)
return server
Expand Down
13 changes: 8 additions & 5 deletions nosqlite.js
Expand Up @@ -353,7 +353,7 @@
// create the temp table
this_flow = this;
return self.find(table, {
rowid: 2
rowid: 1
}, function(err, res) {
var create_temp_table_sql;
row1 = res[0];
Expand Down Expand Up @@ -437,7 +437,10 @@
statement1.reset();
self.bind_obj(statement1, converted_obj);
// step once to do the insert
return statement1.step(function() {
return statement1.step(function(err) {
if ((typeof err !== "undefined" && err !== null)) {
return callback(err);
}
return migrate_row();
});
});
Expand Down Expand Up @@ -480,7 +483,7 @@
});
response.write(JSON.stringify(result));
}
return response.close();
return response.end();
};
// Starts a webserver on the supplied port to serve http requests
// for the instance's associated database.
Expand All @@ -507,7 +510,7 @@
"Content-Type": "text/plain"
});
response.write("Must supply method param");
response.close();
response.end();
return null;
}
table = url.query.table;
Expand Down Expand Up @@ -540,7 +543,7 @@
"Content-Type": "text/plain"
});
response.write(("Unrecognized method: " + (url.query.method)));
return response.close();
return response.end();
}
});
});
Expand Down
13 changes: 6 additions & 7 deletions test/test_nosqlite.coffee
Expand Up @@ -257,8 +257,7 @@ test_find_or_save: ->

test_save_web: ->

db_file: "./test/test_save_web.db"
remove_file(db_file)
db_file: "./test/test_save_bulk.db"
rest: require "restler" if not rest?

#start the listener
Expand Down Expand Up @@ -330,10 +329,10 @@ test_migration: ->
if err? then sys.p err
assert.equal(res, "success", "should migrate table from one schema to another")

test_find()
test_find_or_save()
test_save()
test_save_multiple()
#test_find()
#test_find_or_save()
#test_save()
#test_save_multiple()
#test_migration()
#test_save_bulk()
#test_save_web()
test_save_web()
13 changes: 6 additions & 7 deletions test/test_nosqlite.js
Expand Up @@ -295,8 +295,7 @@
};
test_save_web = function test_save_web() {
var db, db_file, rest;
db_file = "./test/test_save_web.db";
remove_file(db_file);
db_file = "./test/test_save_bulk.db";
if (!(typeof rest !== "undefined" && rest !== null)) {
rest = require("restler");
}
Expand Down Expand Up @@ -385,11 +384,11 @@
});
return db;
};
test_find();
test_find_or_save();
test_save();
test_save_multiple();
//test_find()
//test_find_or_save()
//test_save()
//test_save_multiple()
//test_migration()
//test_save_bulk()
//test_save_web()
test_save_web();
})();

0 comments on commit 348345e

Please sign in to comment.