Permalink
Browse files

updraded web api to node 0.1.90 apis

  • Loading branch information...
1 parent a613f06 commit 348345ef8d1ac5fa856f6274740f440a1e0878b0 @mrjjwright committed Apr 12, 2010
Showing with 26 additions and 24 deletions.
  1. +6 −5 nosqlite.coffee
  2. +8 −5 nosqlite.js
  3. +6 −7 test/test_nosqlite.coffee
  4. +6 −7 test/test_nosqlite.js
View
@@ -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)
@@ -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()
->
@@ -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.
@@ -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
@@ -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
View
@@ -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];
@@ -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();
});
});
@@ -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.
@@ -507,7 +510,7 @@
"Content-Type": "text/plain"
});
response.write("Must supply method param");
- response.close();
+ response.end();
return null;
}
table = url.query.table;
@@ -540,7 +543,7 @@
"Content-Type": "text/plain"
});
response.write(("Unrecognized method: " + (url.query.method)));
- return response.close();
+ return response.end();
}
});
});
@@ -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
@@ -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()
View
@@ -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");
}
@@ -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.