在Array中插入String类型的数据,该数据位于另一个数组中

时间:2015-07-13 16:19:57

标签: meteor

如何在另一个数组中的对象中插入String类型的数据?

以下是我的数组:

productRequirements: [{
    question: "What type of Business Bag do you need?",
    type: "checkbox",
    specifications: [
        "Luggage Bag",
        "Handbag",
        "Shoulder Bag",
        "Soft Bag",
        "Laptop Bag",
        "Tote Bag",
        "Not Sure",
        "Others"]
}, {
    question: "What kind of logo do you prefer on your bag?",
    type: "radio",
    specifications: [
        "OEM",
        "Embossed",
        "Debossed",
        "Printed",
        "Customized",
        "Not Sure",
        "Others"]
}]

我想逐个在specifications中插入字符串,我正在尝试以下代码:

Products.update({
    _id: productId,
    "productSpecifications.Specification": listing["Specification"]
}, {
    $push: {
        "productSpecifications.$.Options": {
            Options: listing["Options"]
        }
    }
})

是插入对象而不是字符串。我怎样才能纠正它?

0 个答案:

没有答案