Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/ObjectId.h
ObjectId is a 12-byte BSON type, constructed using:
- a 4-byte timestamp, - a 3-byte machine identifier, - a 2-byte process id, and - a 3-byte counter, starting with a random value.
In MongoDB, documents stored in a collection require a unique _id field that acts as a primary key. Because ObjectIds are small, most likely unique, and fast to generate, MongoDB uses ObjectIds as the default value for the _id field if the _id field is not specified; i.e., the mongod adds the _id field and generates a unique ObjectId to assign as its value.
Member Functions: timestamp, toString
typedef SharedPtr < ObjectId > Ptr;
ObjectId(
const std::string & id = ""
);
Constructor
virtual ~ObjectId();
Destructor
Timestamp timestamp() const;
Returns the timestamp which is stored in the first four bytes of the id
std::string toString(
const std::string & fmt = "%02x"
) const;
Returns the id in string format. The fmt parameter specifies the formatting used for individual members of the ID char array.