Once you save a function in the system.js collection, you can use the function from any JavaScript context; e.g. $where operator, mapReduce command or db.collection.mapReduce() . 

In the mongo shell, you can use db.loadServerScripts() to load all the scripts saved in the system.js collection for the current database. Once loaded, you can invoke the functions directly in the shell, as in the following example: 

db.loadServerScripts(); echoFunction(3); myAddFunction(3, 5); 

## Upgrade to the Latest Revision of MongoDB 

Revisions provide security patches, bug fixes, and new or changed features that do not contain any backward breaking changes. Always upgrade to the latest revision in your release series. The third number in the MongoDB version number (page 924) indicates the revision. 

## Before Upgrading 

• Ensure you have an up-to-date backup of your data set. See MongoDB Backup Methods (page 184). 

• Consult the following documents for any special considerations or compatibility issues specific to your Mon- goDB release: 

– The release notes, located at Release Notes (page 785). 

– The documentation for your driver. See Drivers 85 page for more information. 

• If your installation includes replica sets , plan the upgrade during a predefined maintenance window. 

• Before you upgrade a production environment, use the procedures in this document to upgrade a staging environ- ment that reproduces your production environment, to ensure that your production configuration is compatible with all changes. 

## Upgrade Procedure 

Important: Always backup all of your data before upgrading MongoDB. 

Upgrade each mongod and mongos binary separately, using the procedure described here. When upgrading a binary, use the procedure Upgrade a MongoDB Instance (page 237). 

Follow this upgrade procedure: 

1. For deployments that use authentication, first upgrade all of your MongoDB drivers . To upgrade, see the documentation for your driver. 

2. Upgrade sharded clusters, as described in Upgrade Sharded Clusters (page 237). 

3. Upgrade any standalone instances. See Upgrade a MongoDB Instance (page 237). 

4. Upgrade any replica sets that are not part of a sharded cluster, as described in Upgrade Replica Sets (page 238). 

