Tuesday 16 May 2017

cassandra current timestamp with node js

in the below insert query when I use dateof(now()) is not working. But new Date('2017-09-01 00:00:00+0000') this one is working. please help me out..

router.post('/recent_activities', function(req, res, next)

{

var body =req.body;

console.log(body);

console.log( body.id + body.setid);

var query ="Insert into recent_activities (id,setid,companyid,activity_name,activity_date,activity_by) values (? , ?, ?, ?, ?, ?)"

client.execute(query,[body.id,body.setid,body.companyid,body.activity_name, dateof(now()),body.activity_by], 

function(err, result) {

if (err) {

      throw err;

    } 

else {

console.log('success!');

}

});

res.json({ id:201, message: 'All Success' });

});

am getting 500 internal server error.

now is not defined

ReferenceError: now is not defined

at /apps/node_cassandra/routes/index.js:96:85

at Layer.handle [as handle_request] 




(/apps/node_cassandra/node_modules/express/lib/router/layer.js:95:5) at next
(/apps/node_cassandra/node_modules/express/lib/router/route.js:137:13) at Route.dispatch
(/apps/node_cassandra/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request]
(/apps/node_cassandra/node_modules/express/lib/router/layer.js:95:5) at /apps/node_cassandra/node_modules/express/lib/router/index.js:281:22


via user3214361

No comments:

Post a Comment