如何将对象推入Mongoose对象子数组

时间:2019-12-09 14:18:36

标签: node.js mongoose

QGraphicsItem::ItemClipsChildrenToShape

我要将 ACTIVITY 对象推送到 campaign-> data-> actions 。 此 ACTIVITY 对象将通过带有browserKey的请求来获得。 此 browserKey profielLink 用于指示广告系列。和profileLink指示 data 数组

的特定对象

我自己尝试过这种方法,但是没有工作

const CampaignSchema = new Schema(
  {
    name: {
      type: String,
      required: true
    },
    userId: {
      type: ObjectId,
      ref: 'User'
    },
    liEmail: {
      type: String,
      required: true
    },
    type: {
      type: String,
      enum: campaignConstants.COMPAIGN_TYPES,
      default: campaignConstants.CUSTOM
    },
    sequences: [
      {
        type: Sequence,
        required: true
      }
    ],
    excludeOption: {
      type: Boolean,
      default: false
    },
    sourceLinks: [String],
    data: [
      {
        targetId: {
          type: ObjectId,
          ref: 'Target'
        },
        profileLink: String,
        name: String,
        headline: String,
        imageurl: String,
        actions: [Activity]
      }
    ],
    browserKey: String
  },
  {
    versionKey: false,
    timestamps: true
  }
)

0 个答案:

没有答案