1BSON::DBRef(3)        User Contributed Perl Documentation       BSON::DBRef(3)
2
3
4

NAME

6       BSON::DBRef - BSON type wrapper for MongoDB DBRefs
7

VERSION

9       version v1.12.2
10

SYNOPSIS

12           use BSON::Types ':all';
13
14           my $dbref = bson_dbref( $oid, $collection_name );
15

DESCRIPTION

17       This module provides a BSON type wrapper for MongoDB Database
18       References <http://docs.mongodb.org/manual/reference/database-
19       references/>.
20
21       A DBRef is a special document format which references another document
22       in the database.  DBRefs are not the same as foreign keys and do not
23       provide any referential integrity or constraint checking. For example,
24       a DBRef may point to a document that no longer exists (or never
25       existed.)
26
27       Use of DBRefs is discouraged, so this module is provided for backwards
28       compatibility.  "Manual references"
29       <https://docs.mongodb.com/manual/reference/database-
30       references/#document-references> are preferred when there is a need to
31       reference other documents.
32

ATTRIBUTES

34   id
35       Required. The "_id" value of the referenced document. If the "_id" is
36       an ObjectID, then you must use a BSON::OID object.
37
38   ref
39       Required. The name of the collection in which the referenced document
40       lives.  Either a MongoDB::Collection object or a string containing the
41       collection name. The object will be coerced to string form.
42
43       This may also be specified in the constructor as '$ref'.
44
45   db
46       Optional. The database in which the referenced document lives. Either a
47       MongoDB::Database object or a string containing the database name. The
48       object will be coerced to string form.
49
50       Not all other language drivers support the $db field, so using this
51       field is not recommended.
52
53       This may also be specified in the constructor as '$db'.
54
55   extra
56       Optional.  A hash reference of additional fields in the DBRef document.
57       Not all MongoDB drivers support this feature and you should not rely on
58       it.  This attribute exists solely to ensure DBRefs generated by drivers
59       that do allow extra fields will round-trip correctly.
60
61       USE OF THIS FIELD FOR NEW DBREFS IS NOT RECOMMENDED.
62

METHODS

64   TO_JSON
65       If the "BSON_EXTJSON" option is true, returns a hashref compatible with
66       MongoDB's extended JSON
67       <https://github.com/mongodb/specifications/blob/master/source/extended-
68       json.rst> format, which represents it as a document as follows:
69
70           { "$ref": "<collection name>", "$id": "<id>" }
71
72       If the "BSON_EXTJSON" option is false, an error is thrown, as this
73       value can't otherwise be represented in JSON.
74

AUTHORS

76       •   David Golden <david@mongodb.com>
77
78       •   Stefan G. <minimalist@lavabit.com>
79
81       This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
82
83       This is free software, licensed under:
84
85         The Apache License, Version 2.0, January 2004
86
87
88
89perl v5.36.0                      2023-01-20                    BSON::DBRef(3)
Impressum