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.
mongodb :: MongoObjectId :: defaultinit
mongodb :: MongoObjectId :: to_json
Internal JSON representation of this Object ID.mongodb $ MongoObjectId :: SELF
Type of this instance, automatically specialized in every classmongodb $ MongoObjectId :: to_s
Formatted asObjectId("5578e5dcf344225cc2378051")
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
mongodb :: MongoObjectId :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).mongodb :: MongoObjectId :: to_json
Internal JSON representation of this Object ID.
# 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