hyperf / hyperf/gotask

mongo_client批量插入的时候部分_id重复无法获取实际插入的数量

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
257
Forks
29
PR merge metrics
No merged PRs in 30d

Description

伪代码:
```
insertMany($insertMany, ['ordered' => false]);
printf("Inserted %d document(s)\n", count($insertResult->getInsertedIDs()));
} catch (ServiceException $e) {
print_r($e->getMessage());
//output like: error 'error while executing mongo command: bulk write error: [{[{E11000 duplicate key error collection: db_aaa.t_table index: _id_ dup key: { _id: "2"}} {E11000 duplicate key error collection: db_aaa.t_table index: _id_ dup key: { _id: "3" }}]}, {}]' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'
} catch (GoridgeException $e) {
//other logic
}
```

ordered是false的时候,会继续插入非重复的数据,但是ServiceException没有提供实际写入的数据,可靠性不好控制。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.