ObjectId class
ObjectId
This class allows you to create and manipulate bson ObjectIds.
Example:
final id = ObjectId();
final id2 = ObjectId.fromHexString('5f527e9b350aa5f9709daf16');
final id3 = ObjectId.fromBytes(
[95, 82, 126, 187, 124, 177, 57, 83, 165, 119, 211, 48],
);
final id4 = ObjectId.fromValues(timestamp, processUnique, counter);
Constructors
- ObjectId()
- Creates ObjectId.
-
ObjectId.fromBytes(List<
int> bytes) - Creates ObjectId from bytes.
- ObjectId.fromHexString(String hexString)
- Creates ObjectId from hex string.
- ObjectId.fromTimestamp(DateTime timestamp)
- Creates ObjectId from provided timestamp.
- ObjectId.fromValues(int millisecondsSinceEpoch, int processUnique, int counter)
- Creates ObjectId from provided values.
Properties
- bytes → Uint8List
-
ObjectId bytes.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- hexString → String
-
Returns hex string for current ObjectId.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timestamp → DateTime
-
Returns the generation date (accurate up to the second) that this
ObjectId was generated.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- byteLength → const int
- Length of the ObjectId in bytes.
- hexStringLength → const int
- Length of the ObjectId hexString.