{
    "mode": "perldoc",
    "parameter": "BSON::DBRef",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/BSON%3A%3ADBRef/json",
    "generated": "2026-06-09T13:48:11Z",
    "synopsis": "use BSON::Types ':all';\nmy $dbref = bsondbref( $oid, $collectionname );",
    "sections": {
        "NAME": {
            "content": "BSON::DBRef - BSON type wrapper for MongoDB DBRefs\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version v1.12.2\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use BSON::Types ':all';\n\nmy $dbref = bsondbref( $oid, $collectionname );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides a BSON type wrapper for MongoDB Database References\n<http://docs.mongodb.org/manual/reference/database-references/>.\n\nA DBRef is a special document format which references another document in the database. DBRefs\nare not the same as foreign keys and do not provide any referential integrity or constraint\nchecking. For example, a DBRef may point to a document that no longer exists (or never existed.)\n\nUse of DBRefs is discouraged, so this module is provided for backwards compatibility. \"Manual\nreferences\" <https://docs.mongodb.com/manual/reference/database-references/#document-references>\nare preferred when there is a need to reference other documents.\n",
            "subsections": []
        },
        "ATTRIBUTES": {
            "content": "id\nRequired. The \"id\" value of the referenced document. If the \"id\" is an ObjectID, then you must\nuse a BSON::OID object.\n\nref\nRequired. The name of the collection in which the referenced document lives. Either a\nMongoDB::Collection object or a string containing the collection name. The object will be\ncoerced to string form.\n\nThis may also be specified in the constructor as '$ref'.\n\ndb\nOptional. The database in which the referenced document lives. Either a MongoDB::Database object\nor a string containing the database name. The object will be coerced to string form.\n\nNot all other language drivers support the $db field, so using this field is not recommended.\n\nThis may also be specified in the constructor as '$db'.\n\nextra\nOptional. A hash reference of additional fields in the DBRef document. Not all MongoDB drivers\nsupport this feature and you should not rely on it. This attribute exists solely to ensure\nDBRefs generated by drivers that do allow extra fields will round-trip correctly.\n\nUSE OF THIS FIELD FOR NEW DBREFS IS NOT RECOMMENDED.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "TOJSON\nIf the \"BSONEXTJSON\" option is true, returns a hashref compatible with MongoDB's extended JSON\n<https://github.com/mongodb/specifications/blob/master/source/extended-json.rst> format, which\nrepresents it as a document as follows:\n\n{ \"$ref\": \"<collection name>\", \"$id\": \"<id>\" }\n\nIf the \"BSONEXTJSON\" option is false, an error is thrown, as this value can't otherwise be\nrepresented in JSON.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   David Golden <david@mongodb.com>\n\n*   Stefan G. <minimalist@lavabit.com>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.\n\nThis is free software, licensed under:\n\nThe Apache License, Version 2.0, January 2004\n",
            "subsections": []
        }
    },
    "summary": "BSON::DBRef - BSON type wrapper for MongoDB DBRefs",
    "flags": [],
    "examples": [],
    "see_also": []
}