Some notes:

- why you're not getting the error on insert? It's just if (!err)
- what's the difference between the one that works and the one that doesn't? Is 
your req.body.whatever sanitized? Inserting stuff and querying like that might 
be risky. 

Try to log what you're trying to insert. And try to insert manually after that. 
If it doesn't work, it's something between your data and Cassandra. If it 
works, it's an issue with your code.

> On May 24, 2014, at 1:14 AM, Ankit ladhania <[email protected]> wrote:
> 
> 
> 
> 
> I dont know what is happening sometimes cassandra is easily committing the 
> post and storing data in ~20ms and other times the post takes ~120000ms but 
> the post is not committed(i.e stored). Any Suggestion Guys i'm struggling 
> with this for two days
> I dont find any error in the bellow queries . I have indexed checked column. 
> 
> Here is my main app file:
> 
>      var express=require('express'),
>     app=express(),
>     morgan=require('morgan'),
>     bodyParser=require('body-parser'),
>     methodOverride=require('method-override'),
>     cookieParser=require('cookie-parser'),
>     sessions=require('express-session'),
>     passport=require('passport'),
>     path=require('path'),
>     cassandra=require('node-cassandra-cql'),
>     port=3000;
> 
>      var cassandraSettings=require('./config/cassandra').setting;
>      cassandraClient = new cassandra.Client(cassandraSettings);
>      cassandraClient.connect(function(error){
>     if(error)
>            console.log('error - ' + error);
>        else
>            console.log('Logged In to Cassandra');
>      });
> 
> 
> 
>     var cassandraConfig={
>     readConsistency:cassandra.types.consistencies.one,
>     writeConsistency:cassandra.types.consistencies.any,
>     cassandra:cassandra,
>     cassandraClient:cassandraClient
>     }
> 
>     require('./config/passport')(passport,cassandraConfig);
> 
>     app.use(morgan('dev'))
>     .use(bodyParser())
>     .use(methodOverride())
>     .use(cookieParser())
>     
> .use(sessions({name:"sid",cookie:{maxAge:1000*60*60*24*30},secret:"Ankit"}))
>     .use(passport.initialize())
>     .use(passport.session());
> 
> 
> 
> 
>     //url for statics
>     app.use('/static', express.static(__dirname + '/views'));
> 
>      require('./routes/login')(app,passport);
>      require('./routes/signup')(app,passport);
>      //Used to insert Sport, League, TeamDetails 
>       require('./routes/private/insert_sport_detail')(app,cassandraConfig);
>      //require('./routes/private/insert_league_detail')(app,cassandraConfig);
> 
>      app.listen(port);
> 
> My cassandra route.js:
> 
>       var queries={
>     insert:{
>         sport_detail:{
>             query:'INSERT INTO 
> only_sport_detail(sportid,sport_name,sport_short_name,time_made,checked) 
> VALUES (?,?,?,?,?)'
>         },
>         league_detail:{
>             query:'INSERT INTO 
> only_league_detail(leagueid,league_name,league_short_name,league_abbreviation,league_location,time_made,checked)
>  VALUES (?,?,?,?,?,?,?)'
>         }
>     },
>     retrieve:{
>         sport_detail:{
>             query:'SELECT * FROM only_sport_detail WHERE checked=?'
>         },
>         league_detail:{
>             query:'SELECT * FROM only_league_detail WHERE checked=?'
>         }
>     }
>      };
> 
>        module.exports=function(app,cassandraConfig){
>     var cassandraClient=cassandraConfig.cassandraClient;
>     var writeConsistency=cassandraConfig.writeConsistency;
>     var readConsistency=cassandraConfig,readConsistency;
>     var cassandra=cassandraConfig.cassandra;
>     app.get('/insert/detail/sport',function(req,res){
>         res.sendfile('views/insert/sport_detail.html');
>     });
>     app.post('/insert/detail/sport',function(req,res){
>         sportid=cassandra.types.timeuuid();
>         cassandraClient.executeAsPrepared(
>             queries.insert.sport_detail.query,
>             [sportid,req.body.sport_name,req.body.sport_short_name,{value: 
> new Date(), hint: cassandra.types.dataTypes.timestamp},1],
>             writeConsistency,
>             function(err){
>                 if(!err)
>                 {
> 
>                     cassandraClient.executeAsPrepared(
>                         queries.retrieve.sport_detail.query,
>                         [1],
>                         function(err,result){
>                             if(err)
>                             {
>                                 console.log(err);
>                                 res.send('Sorry error');
>                                 res.end();
>                             }
>                             else
>                             {
>                                 res.json(result.rows);
>                                 res.end();
>                             }
>                         }
>                     );
>                 }
>             }
>         );
>         
>     });
>     
>     app.get('/get/detail/sport',function(req,res){
>         cassandraClient.executeAsPrepared(
>             queries.retrieve.sport_detail.query,
>             [1],
>             function(err,result){
>                 if(err)
>                 {
>                     console.log(err);
>                     res.send('Sorry error');
>                     res.end();
>                 }
>                 else
>                 {
>                     res.json(result.rows);
>                     res.end();
>                 }
>             }
>         );
>     });
> };
> -- 
> Job board: http://jobs.nodejs.org/
> New group rules: 
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules: 
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/nodejs/f6aa1a20-d40e-4ea9-ae25-06a66f5d0f13%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/9108D180-6D72-4D47-843C-2838F0663B22%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to