mongodb increment counter on select

Is there any way to update the documents by incrementing ($incr) their counter field (lets say there is a counter field) by 1 when the documents are returned by a find command ?

or,

there are no ways but to update this manually?

Answers


Unfortunately there is no support for internal triggering or anything similar in MongoDB. You'll have to do that manually.

Here is the discussion about the triggers feature.


Have you looked at using findAndModify? You can find the doc, atomically update it, and then return it in one operation.


Need Your Help

How to update existing Phonegap Build app with Phonegap CLI

cordova phonegap-build

I am just moving from Phonegap 2.9.0 to 3.2.0 and I am using Phonegap Build. However, I am struggling with the update of my existing apps in the Phonegap Build.

displaying image hover graph in rickshaw, jquery or d3.js

javascript jquery css html5 rickshaw

Do anybody know whether images can be displayed on mouse hover event on rickshaw or d3 graph. if so please state a example. Thanks in advance. help will be appreciated.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.