1

嘿伙计们,我正在尝试像这样使用 Meteor upsert。

console.log(vendorReviewArr);
var updateQuery = {$set: {vendorID: vendorIDVal}, $push: {reviews:vendorReviewArr}};

VendorReviews.upsert(
    {vendorID: vendorIDVal},
    updateQuery,
    function(error){
        console.log("There is an error!");
        console.log(error);
        console.log("VENDOR ID: "+vendorIDVal);
    }
);

vendorReviewArr 在 console.log 中看起来像这样

{ title: 'This is a test title title title',
body: 'This is a test title body' }

这是我的 VendorReviews 的简单模式。

VendorReviews = new Mongo.Collection('vendorsReviews'); //Define the collection.

VendorReviewObjSchema = new SimpleSchema({
    authorID: {
        type: String,
        label: "authorID",
        autoValue: function(){
            return this.userId
        },
        optional: true
    },
    title: {
        type: String,
        label: "title",
        min: 25,
    },
    body: {
        type: String,
        label: "body",
        min: 25,
        max: 1000
    }
});

VendorReviewsSchema = new SimpleSchema({
    vendorID: {
        type: String,
        label: "vendorID HERE",

    },
    reviews : {
        type : [VendorReviewObjSchema],
        label : "Vendor Reviews",
        optional: true
    }

});

VendorReviews.attachSchema(VendorReviewsSchema);

现在由于某种原因,当从服务器调用此方法时,集合不记录任何数据。我所看到的只是

I20160110-23:54:38.031(-5)? There is an error!
I20160110-23:54:38.032(-5)? null
I20160110-23:54:38.032(-5)? VENDOR ID: iXdqzcSNmMwrRj3jf

检查 mongo shell 中的集合显示没有数据。

任何人都可以帮我解决这个问题吗?感谢您的阅读。

4

0 回答 0