I won't help you with Seq, but it looks as pretty easy case for other
concept I'm familiar with, check: https://gist.github.com/3149506
I'm not sure how you want to fetch md5 and servers info so I just hidden
that logic between fetchMd5 and fetchServers functions.
On Thursday, July 19, 2012 7:40:43 PM UTC+2, RhythmicDevil wrote:
>
> I am missing something really obvious here and I hope you can help me. I
> am trying to achieve the following:
>
> Fetch an array of results
>
> For each item in results
> -- fetch md5 data and add to item
> -- fetch server data and add to item
> -- insert item into DB
>
> I'll paste my Seq chain below but here is the problem. In the parEach() I
> get a row as expected from the previous step. I create my object and fill
> in some data. I then call the two par() steps. The problem is that the arg
> to callback in par() is wrong. Instead of getting the cncInfo object I get
> the row object that was passed to the parEach() callback.
>
> I added console logs with [A], [B], and [C]. My expectation is that at
> each step I should be seeing the same object. This is not the case. The
> value at [B] and at [C] is the row object passed to parEach not the cncInfo
> object.
>
> Where am I going wrong?
>
> Thanks for any advice you can give me.
> Thanks
> Steve
>
>
>
> Seq().seq('source', function(){
> console.log('[INFO]', 'Starting sequence');
> var _this = this;
> /*
> * Get the source data
> */
> var q = 'SELECT A.* FROM BotCCServer A LIMIT 1';
> DbSource.query(q, function(err, result, fields){
> if(err){
> cleanup(err);
> }else{
> _this(null, result);
> }
> });
>
> }).flatten().parEach(function(row, i){
> console.log('[INFO]', 'Par Each');
>
> var _this = this;
> var cncInfo = new CNCInfo();
> cncInfo._id = row.entry_id;
> cncInfo.entry_id = row.entry_id;
> cncInfo.entry_type = row.entry_type;
>
> console.log('[A]',cncInfo);
> _this(null, cncInfo);
>
>
> }).par('md5s', function(cncInfo){
> console.log('[INFO]', 'Seq MD5');
> console.log('[B]', this.stack);
>
> var _this = this;
> //cncInfo.md5s.push(cncInfo.entry_id);
> _this(null, cncInfo);
>
> }).par('servers', function(cncInfo){
> console.log('[INFO]', 'Seq servers');
> console.log('[C]', cncInfo);
>
> var _this = this;
> //cncInfo.servers.push(cncInfo.entry_id);
> _this(null, cncInfo);
>
> }).seq('insert', function(cncInfo){
> console.log('[INFO]', 'Seq insert');
>
> var _this = this;
> DbDest.write('botnet_cnc_info', cncInfo, function(err, resp){
> if(err){
> _this(err);
> }else{
> _this(null, resp);
> }
> });
>
> }).seq('final', function(resp){
>
> cleanup(null, resp);
>
> }).catch(function(err){
> cleanup(err);
> });
>
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en