has no method on #17

Closed
opened 2015-01-30 13:26:59 +00:00 by MortalCatalyst · 2 comments
MortalCatalyst commented 2015-01-30 13:26:59 +00:00 (Migrated from github.com)

have written a very basic query but when running I ge this error

sayth@:~/Projects$ node test2.js

/home/sayth/Projects/node_modules/basex/index.js:220
this.on("drain", function() {
^
TypeError: Object #

have written a very basic query but when running I ge this error sayth@:~/Projects$ node test2.js /home/sayth/Projects/node_modules/basex/index.js:220 this.on("drain", function() { ^ TypeError: Object #<Object> has no method 'on' at Object.Session (/home/sayth/Projects/node_modules/basex/index.js:220:10) at Object.<anonymous> (/home/sayth/Projects/test2.js:2:19) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:929:3 sayth@:~/Projects$ ``` javascript var basex=require("basex"); var session=basex.Session('localhost', 1984,'admin','admin') var query=session.query('/Meeting/Races/Race/RaceEntries/RaceEntry/Form/ResultsSummaries/ResultsSummary/@Wins>=1') console.log(session); ```
apb2006 commented 2015-01-30 20:07:52 +00:00 (Migrated from github.com)

Hi,
Your code does not seems to specify a data source. I.e. there is no doc("..") or db open statement..
Could this be the problem?

Hi, Your code does not seems to specify a data source. I.e. there is no doc("..") or db open statement.. Could this be the problem?
apb2006 commented 2015-01-31 00:21:43 +00:00 (Migrated from github.com)

Also it does not use callbacks, these are required when working with Node. To execute some xquery use

var query=session.query(xquery);
query.results(callback);

See https://github.com/apb2006/basex-node/blob/master/docs/commands.md#introduction for a callback example.
If you do this you will see the BaseX response

Error: Stopped at ., 1/2:
[XPDY0002] root(): no context value bound.

This is because your XQuery has no context. You need to specify the location of the data you want to query. I suggest you try to get what you want running in the BaseXGUI before trying it with this API.

Also it does not use callbacks, these are required when working with Node. To execute some xquery use ``` var query=session.query(xquery); query.results(callback); ``` See https://github.com/apb2006/basex-node/blob/master/docs/commands.md#introduction for a callback example. If you do this you will see the BaseX response ``` Error: Stopped at ., 1/2: [XPDY0002] root(): no context value bound. ``` This is because your XQuery has no context. You need to specify the location of the data you want to query. I suggest you try to get what you want running in the BaseXGUI before trying it with this API.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quodatum/basex-node#17
No description provided.