yii\mongodb\Command::insert PHP Method

insert() public method

Inserts new document into collection.
public insert ( string $collectionName, array $document, array $options = [] ) : MongoDB\BSON\ObjectID | boolean
$collectionName string collection name
$document array document content
$options array list of options in format: optionName => optionValue.
return MongoDB\BSON\ObjectID | boolean inserted record ID, `false` - on failure.
    public function insert($collectionName, $document, $options = [])
    {
        $this->document = [];
        $this->addInsert($document);
        $result = $this->executeBatch($collectionName, $options);
        if ($result['result']->getInsertedCount() < 1) {
            return false;
        }
        return reset($result['insertedIds']);
    }