Laravel-mongodb: [Feature Request] Add options support to insert and delete methods of Query Builder

Created on 23 Apr 2020  路  10Comments  路  Source: jenssegers/laravel-mongodb

Is your feature request related to a problem?

No, is related to a need.
My need is to be able to use writeConcern option to allow async write operations.

Describe the solution you'd like

I'd like to pass options parameter to insert and delete methods, as it already happens for update method.

Additional context

I've already created a PR #2029

Most helpful comment

I need this feature addition as well

All 10 comments

@danielerota can you show example for this async write operation?

@Smolevich I need to log API operation, so the code can't stop if log insert (into mongodb) fail.
An example call here:

$collection = app('db')->connection('mongodb')->collection('characters');
try {
     $collection->insert(array("_id"=>"unique21"), array("writeConcern" => new WriteConcern(0)));
}catch (\Exception $e) {        }

This specific usage is useful in case you are not interested about the status of the operation (e.g. for logging). In this way you don't have to wait for the acknowledge from MongoDB and the script can continue the execution, saving time.
However, the options array can contain other useful MongoDB options. Currently, only update method handles the $options parameter, so I think id would be right that also insert and delete support it.

I need this feature addition as well

I need this feature addition as well

+1

+1

+1

+1

+1

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HassanIbrahim picture HassanIbrahim  路  3Comments

pirmax picture pirmax  路  3Comments

imrannazirbhat picture imrannazirbhat  路  3Comments

ricardofontanelli picture ricardofontanelli  路  3Comments

kschethan picture kschethan  路  3Comments