javascript - Chaining Asynchronous Callback Nodejs -


i m working on project orientdb m using gremlin graph language implement fonctionnality , confuse async callback chaining want instruction

var length = g.getedges().count(); 

such getedges() async function

var grex = require('grex'); var async = require('async'); var gremlin = grex.gremlin; var g = grex.g; var client = grex.createclient( {     host: 'localhost',     port: 8182,     graph: 'orientdbsample' } );  function orientgraph(obj) {     this.result = obj.result;     this.results = obj.results;      this.getedges = function(callback) {         async.auto({             getv: function(cb) {                 client.fetch(g.e(), function(err, response) {                     if (err) return cb(err);                     return cb(null, response);                 });             }         }, function(err, res) {             callback(err, new orientgraph({                 results: res.getv             }));         });     }      this.count = function(){         return this.results.length;     } module.exports = orientgraph;  } 

and in server.js file use

var gremapi = require('./app/api'); var og = new gremapi({   results : [] }); og.getedges(function(err,data){   console.log(data.count()); }).count(); 

the error :

/home/xar/dev/stage/gremlin/server.js:28 }).count();   ^ typeerror: cannot read property 'count' of undefined     @ object.<anonymous> (/home/xar/dev/stage/gremlin/server.js:28:3)     @ module._compile (module.js:460:26)     @ object.module._extensions..js (module.js:478:10)     @ module.load (module.js:355:32)     @ function.module._load (module.js:310:12)     @ function.module.runmain (module.js:501:10)     @ startup (node.js:129:16)     @ node.js:814:3 

thank


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -