Skip to content

Commit

Permalink
Query more
Browse files Browse the repository at this point in the history
  • Loading branch information
apb2006 committed Oct 4, 2011
1 parent c12e3d3 commit 14d8499
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
7 changes: 4 additions & 3 deletions examples/QueryBindExample.js
Expand Up @@ -4,6 +4,7 @@
*/

var basex = require("../index");
basex.debug_mode = true;
var session = new basex.Session("localhost", 1984, "admin", "admin");

// create query instance
Expand All @@ -14,11 +15,11 @@ var query = session.query(input);
query.bind("name", "number");

// print results
query.execute(basex.print);
//query.execute(basex.print);

// close query instance
query.close();
//query.close();

// close session
session.close();
//session.close();

24 changes: 16 additions & 8 deletions index.js
Expand Up @@ -88,6 +88,9 @@ var BaseXStream = function(host, port, username, password) {
} else {
var r=self.getResponse();
if(r){
if (exports.debug_mode) {
console.log("response: ",r);
};
self.current_command.callback(null,r);
self.current_command=null;
self.doNext();
Expand Down Expand Up @@ -246,47 +249,50 @@ var Query = function(session,query){

this.close=function(callback){
self.session.send_command({
send: "\x02"+ this.id+"\x00",
send: "\x02"+ self.id+"\x00",
parser:self.session.getResponse,
callback:callback
});
};

this.bind=function(name,value,callback){
console.log("BIND",self.id);
/*
self.session.send_command({
send: "\x03"+ this.id +"\x00"+name+"\x00"+value+"\x00",
send: "\x03"+ self.id +"\x00"+name+"\x00"+value+"\x00",
parser:self.session.getResponse,
callback:callback
});
*/
};

this.iter=function(callback){
self.session.send_command({
send: "\x04"+ this.id+"\x00",
send: "\x04"+ self.id+"\x00",
parser:self.session.getResponse,
callback:callback
});
};

this.execute=function(callback){
self.session.send_command({
send: "\x05"+ this.id+"\x00",
send: "\x05"+ self.id+"\x00",
parser:self.session.getResponse,
callback:callback
});
};

this.info=function(callback){
self.session.send_command({
send: "\x06"+ this.id+"\x00",
send: "\x06"+ self.id+"\x00",
parser:self.session.getResponse,
callback:callback
});
};

this.options=function(callback){
self.session.send_command({
send: "\x07"+ this.id+"\x00",
send: "\x07"+ self.id+"\x00",
parser:self.session.getResponse,
callback:callback
});
Expand All @@ -295,9 +301,11 @@ var Query = function(session,query){
// request id
session.send_command({
send : CHR0+query + CHR0,
parser : self.getResponse,
parser : self.session.getResponse,
callback : function(err,reply){
console.log("query",id);
self.id=reply.result;
console.log("query id: ",query);
console.log("ID: ",self.id);
}
});
};
Expand Down

0 comments on commit 14d8499

Please sign in to comment.