Jake 1986 Jake 1986 - 1 year ago 83
jQuery Question

How to $inc MongoDB Document Field with AJAX?

I am trying to $inc a MongoDB field each time a "Like" button is clicked. Because there is no data that I need to pass to the server (but maybe there is?), I am not sure what value to put for the

key in my

The post route below shows what I am trying to do when the "Like" button is clicked:

app.post('/like', function(req,res){
var query = req.session.mostRecentQuiz;
query, { $inc: {"likes": 1 } }, function (err, result) {
if (err) throw err;
} );

On page JS:

url: "/like",
method: "POST",
data: , //what would go here?
//I just need to $inc each time "Like is clicked.
success: function(data){

Thanks in advance for any answers.

Answer Source

true for like, false for unlike

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download