ActiveUnits / mongodb-rest

REST Server for MongoDB (using node.js)
www.degrunt.net
GNU Lesser General Public License v3.0
25 stars 11 forks source link

How to increment several counters at once #1

Closed adomado closed 12 years ago

adomado commented 12 years ago

Hi,

If I have a collection called as "unicorns" I want to increment a counter called "hit" for each unicorn which is male

$j.ajax({  
  url : "http://localhost:3000/test/unicorns?query=" + encodeURI(JSON.stringify({gender : "m"})),   
  data : JSON.stringify({'$inc' : {hits: 1}}),   
  type : "PUT",   
  contentType : "application/json",   
  success : function(d) {     
    console.log("Success");     
    console.log(d);   
  },   
  error : function(d) { 
    console.log("error");     
    console.log(d)   
  } 
});

Is this the correct way to do it? My counters are not updating...

Thanks!

outbounder commented 12 years ago

Hi,

I've just pushed update (v2.0.7) which should support what you've found missing (it wasn't been supported earlier :)

Kind regards, Boris

On Fri, Sep 16, 2011 at 3:01 PM, AdoMado.com reply@reply.github.com wrote:

Hi,

If I have a collection called as "unicorns" I want to increment a counter called "hit" for each unicorn which is male

$j.ajax({
 url : "http://localhost:3000/test/unicorns?query=" + encodeURI(JSON.stringify({gender : "m"})),
 data : JSON.stringify({'$inc' : {hits: 1}}),
 type : "PUT",
 contentType : "application/json",
 success : function(d) {
   console.log("Success");
   console.log(d);
 },
 error : function(d) {
   console.log("error");
   console.log(d)
 }
});

Is this the correct way to do it? My counters are not updating...

Thanks!

Reply to this email directly or view it on GitHub: https://github.com/ActiveUnits/mongodb-rest/issues/1

adomado commented 12 years ago

Awesome! Will check & let you know.

Thanks a ton!

adomado commented 12 years ago

Works perfect. Thanks!

outbounder commented 12 years ago

Hi, I'm glad to hear that, please keep in mind that I've added some more upgrades and fixes, so use the latest version from master...

On Mon, Sep 19, 2011 at 8:06 AM, AdoMado.com reply@reply.github.com wrote:

Works perfect. Thanks!

Reply to this email directly or view it on GitHub: https://github.com/ActiveUnits/mongodb-rest/issues/1#issuecomment-2130442

adomado commented 12 years ago

Doing that already :) Cheers!