"SequoiaDB Giant Sequoia Database" upsert() Overview 2

options option

Note:

  • hintThe usage of parameters is the same as that of find() .

  • When the  cond parameter does not match the record in the collection, upsert will generate a record and insert it into the collection. The record generation rule is: first take out the key-value pairs corresponding to the $et and $all operators from the cond parameter, and generate an empty record if there is none. Then use the rule to update it, and finally add the key-value pair in setOnInsert.

  • Currently, partition key updates are not supported on partition sets. If it  KeepShardingKey is true and there is a partition key field in the update rule, an error -178 will be reported.

return value

  • The detailed result information (BSONObj object) is returned successfully, the structure is as follows:

    {
        UpdatedNum  : <INT64>  成功更新的记录数,包括匹配但未发生数据变化的记录,
        ModifiedNum : <INT64>  成功更新且发生数据变化的记录数,
        InsertedNum : <INT32>  成功插入的记录数,仅在 upsert 下生效
    }

    Throws an error, and outputs the error, by () getLastErrMsg obtain error information or by getLastError () Gets error code. The error information object includes detailed result information.

Click on Jushan Database Documentation Center for more information

Guess you like

Origin blog.csdn.net/weixin_45890253/article/details/112983961