ObjectId The mongo shell provides the ObjectId() wrapper class around the ObjectId data type. To generate a new ObjectId, use the following operation in the mongo shell: 

new ObjectId 

## See 

ObjectId (page 176) for full documentation of ObjectIds in MongoDB. 

NumberLong By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberLong() wrapper to handle 64-bit integers. 

The NumberLong() wrapper accepts the long as a string: 

NumberLong("2090845886852") 

The following examples use the NumberLong() wrapper to write to the collection: 

db.collection.insert( { _id: 10, calc: NumberLong("2090845886852") } ) db.collection.update( { _id: 10 }, { $set: { calc: NumberLong("2555555000000") } } ) db.collection.update( { _id: 10 }, { $inc: { calc: NumberLong(5) } } ) 

Retrieve the document to verify: 

db.collection.findOne( { _id: 10 } ) 

In the returned document, the calc field contains a NumberLong object: 

{ "_id" : 10, "calc" : NumberLong("2555555000005") } 

If you use the $inc to increment the value of a field that contains a NumberLong object by a float , the data type changes to a floating point value, as in the following example: 

1. Use $inc to increment the calc field by 5 , which the mongo shell treats as a float: 

db.collection.update( { _id: 10 }, { $inc: { calc: 5 } } ) 

2. Retrieve the updated document: 

db.collection.findOne( { _id: 10 } ) 

In the updated document, the calc field contains a floating point value: 

{ "_id" : 10, "calc" : 2555555000010 } 

NumberInt By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberInt() constructor to explicitly specify 32-bit integers. 

## Check Types in the mongo Shell 

To determine the type of fields, the mongo shell provides the instanceof and typeof operators. 

