mongodb update push array

前端 未结 3 2013
轻奢々
轻奢々 2021-01-14 15:33

I have the following schema. I am using node.js with mongodb

attributes: {
    type: { type: \'string\' },
    title: { type:\'string\' },
    description:          


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 16:25

    You are trying to insert an array as an element into your array. You may want to look at $pushAll as a short term solution. This operator is deprecated however see here.

    Alternatively you can simply iterate over your array, and each iteration push an element from your array into attachments (this is the recommended approach by Mongo devs).

提交回复
热议问题