Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
MongoDB\InsertOneResult Class Reference

Public Member Functions

 __construct (WriteResult $writeResult, $insertedId)
 
 getInsertedCount ()
 Return the number of documents that were inserted.
 
 getInsertedId ()
 Return the inserted document's ID.
 
 isAcknowledged ()
 Return whether this insert was acknowledged by the server.
 

Constructor & Destructor Documentation

◆ __construct()

MongoDB\InsertOneResult::__construct ( WriteResult $writeResult,
$insertedId )
Parameters
mixed$insertedId

Member Function Documentation

◆ getInsertedCount()

MongoDB\InsertOneResult::getInsertedCount ( )

Return the number of documents that were inserted.

This method should only be called if the write was acknowledged.

See also
InsertOneResult\isAcknowledged()
Return values
integer|null
Exceptions
BadMethodCallExceptionis the write result is unacknowledged

◆ getInsertedId()

MongoDB\InsertOneResult::getInsertedId ( )

Return the inserted document's ID.

If the document had an ID prior to inserting (i.e. the driver did not need to generate an ID), this will contain its "_id". Any driver-generated ID will be a MongoDB\BSON\ObjectId instance.

Return values
mixed

◆ isAcknowledged()

MongoDB\InsertOneResult::isAcknowledged ( )

Return whether this insert was acknowledged by the server.

If the insert was not acknowledged, other fields from the WriteResult (e.g. insertedCount) will be undefined.

If the insert was not acknowledged, other fields from the WriteResult (e.g. insertedCount) will be undefined and their getter methods should not be invoked.

Return values
boolean

The documentation for this class was generated from the following file: