mongodb :: MongoObjectId :: defaultinit
# MongoDB Object ID representation.
#
# For ObjectIDs, MongoDB uses the `ObjectId("hash")` notation.
# This notation is replicated by the `to_s` service.
#
# Since the MongoDB notation is not JSON complient, the mongoc wrapper uses
# a JSON based notation like `{"$oid": "hash"}`.
# This is the notation returned by the `to_json` service.
class MongoObjectId
private var native: BSONObjectId = new BSONObjectId
private init with_native(native: BSONObjectId) do
self.native = native
end
# The unique ID as an MongoDB Object ID string.
fun id: String do return native.id
# Internal JSON representation of this Object ID.
#
# Something like `{"$oid": "5578e5dcf344225cc2378051"}`.
fun to_json: JsonObject do
var obj = new JsonObject
obj["$oid"] = id
return obj
end
# Formatted as `ObjectId("5578e5dcf344225cc2378051")`
redef fun to_s do return "ObjectId({id})"
end
lib/mongodb/mongodb.nit:163,1--193,3