Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.              
  2. Prices.prototype.getSymbols = function(cb){
  3.     this.db.query("SELECT symbols.*, exchanges.exchange FROM symbols, exchange WHERE symbols.id_exchange = exchange.id", function(err, rows){
  4.         if (err) return cb(err)
  5.         cb(null, rows)  
  6.     })  
  7. }
  8.  
  9.  
  10. Prices.prototype.parseSymbols = function(symbols, cb){
  11.     ;(process(){
  12.        var symbol = symbols.pop()
  13.        if (!symbol) return cb()
  14.        //....
  15.        return process()      
  16.     })();                                                        
  17. }
  18.            
  19.  
  20. Prices.prototype.end = function(){
  21.     self.db.end(function(){   })
  22. }
  23.  
  24.  
  25. Prices.prototype.start = function(){
  26.     var self = this
  27.    
  28.     this.setLastDate(function(err, date){
  29.         if (err) return self.end()  
  30.         self.getSymbols(symbols)                                                  
  31.     })
  32.    
  33.     function symbols(err, symbols){
  34.         if (err) return self.end()                
  35.         self.parseSymbols(symbols, self.end)
  36.     }
  37. }