MongoDB Update (Insert a List of Item to an Array)

后端 未结 5 1738
滥情空心
滥情空心 2021-01-02 16:12

I want to add several items to arrays of several rows in Mongo. How can I do this?

I want to start with this:

{\'x\': \'h\', arr: [1,2,3] }
{\'x\':          


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 16:28

    $pushAll
    Deprecated since version 2.4: Use the $push operator with $each instead.

    The $pushAll operator appends the specified values to an array.

    The $pushAll operator has the form:

    { $pushAll: { : [ , , ... ] } }
    

    If you specify a single value, $pushAll will behave as $push.

提交回复
热议问题