forked from mongodb/docs-php-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMongoDBGridFSBucket__construct.txt
132 lines (95 loc) · 3.47 KB
/
MongoDBGridFSBucket__construct.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
======================================
MongoDB\\GridFS\\Bucket::__construct()
======================================
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\GridFS\Bucket::__construct()
Constructs a new :phpclass:`Bucket <MongoDB\GridFS\Bucket>` instance.
.. code-block:: php
function __construct(
MongoDB\Driver\Manager $manager,
string $databaseName,
array $options = []
)
Parameters
----------
``$manager`` : :php:`MongoDB\Driver\Manager <class.mongodb-driver-manager>`
The :php:`Manager <mongodb-driver-manager>` instance from the extension. The
manager maintains connections between the driver and MongoDB.
``$databaseName`` : string
The name of the database.
``$options`` : array
An array specifying the desired options.
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Name
- Type
- Description
* - bucketName
- string
- The bucket name, which will be used as a prefix for the files and
chunks collections. Defaults to ``"fs"``.
* - chunkSizeBytes
- integer
- The chunk size in bytes. Defaults to ``261120`` (i.e. 255 KiB).
* - codec
- MongoDB\\Codec\\DocumentCodec
- The default :doc:`codec </data-formats/codecs>` to use for bucket methods
that return a file document (e.g. :phpmethod:`MongoDB\GridFS\Bucket::find()`).
.. versionadded:: 1.17
* - readConcern
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
- The default read concern to use for bucket operations. Defaults to the
manager's read concern.
* - readPreference
- :php:`MongoDB\Driver\ReadPreference <class.mongodb-driver-readpreference>`
- The default read preference to use for bucket operations. Defaults to
the manager's read preference.
* - typeMap
- array
- Default :php:`type map
<manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`
to apply to cursors, which determines how BSON documents are converted
to PHP values. The library uses the following type map by default:
.. code-block:: php
[
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
]
* - writeConcern
- :php:`MongoDB\Driver\WriteConcern <class.mongodb-driver-writeconcern>`
- The default write concern to use for bucket operations. Defaults to the
manager's write concern.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior
--------
If you construct a Bucket explicitly, the Bucket inherits any options
from the :php:`MongoDB\Driver\Manager <class.mongodb-driver-manager>` object.
If you select the Bucket from a :phpclass:`Database <MongoDB\Database>` object,
the Bucket inherits its options from that object.
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket);
The output would then resemble:
.. code-block:: none
object(MongoDB\GridFS\Bucket)#3053 (2) {
["bucketName"]=>
string(4) "test"
["databaseName"]=>
string(11) "phplib_test"
}
See Also
--------
- :phpmethod:`MongoDB\Database::selectGridFSBucket()`