How do I perform mass updates for entities? Suppose I want to publish 50 nodes at once. How should I do that?
You can use Views bulk operations module which support the mass update on the Drupal site.
This module augments Views by allowing bulk operations to be executed on the displayed rows. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied. Drupal Core or Rules actions can be used.
As you said that you want to update the number of nodes, so there is already module in Drupal Administration Views which replace administrative pages with views.
- Filter all administrative views via AJAX.
- Perform any kind of bulk/mass operations on items in administrative views.
- Filter content by title, node type, author, published status, and/or vocabulary.
- Filter comments by title, author, node title, or published status.
- Filter users by name, ban/blocked status, or user roles.
Or, if you want to update using code, you can follow harshal's answer.