AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

MongoDB\Database::__construct()

MongoDB\Database::__construct()

新しいDatabaseインスタンスを構築します。

function __construct(
MongoDB\Driver\Manager $manager,
string $databaseName,
array $options = []
)
$manager : MongoDB\Driver\Manager
拡張機能からの マネージャーインスタンス。マネージャーはドライバーとMongoDBの間の接続を維持します。
$databaseName : string
データベースの名前。
$options : 配列

必要なオプションを指定する配列。

名前
タイプ
説明

builderEncoder

MongoDB\Codec\Encoder

クエリ ビルダと集計ビルダに使用するエンコード。設定されていない場合、このオプションはデフォルトで MongoDB\Builder\BuilderEncoderクラスの新しいインスタンスになります。

バージョン1.21の新機能。

ReadConcern

データベース操作に使用するデフォルトの読み取り保証 (read concern) です。 デフォルトは、マネージャーの読み取り保証 (read concern) です。

readPreference

データベース操作に使用するデフォルトの読み込み設定 (read preference) 。 デフォルトは、マネージャーの読み込み設定 (read preference) です。

typeMap

配列

Default type map to apply to cursors, which determines how BSON documents are converted to PHP values. The library uses the following type map by default:

[
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
]

writeConcern

データベース操作に使用するデフォルトの書込み保証 (write concern) です。 デフォルトは、マネージャーの書込み保証 (write concern) です。

MongoDB\Exception\InvalidArgumentException は、パラメータまたはオプションの解析に関連するエラーの場合は です。

If you construct a Database explicitly, the Database inherits any options from the MongoDB\Driver\Manager object. If you select the Database from a Client object, the Database inherits its options from that object.