Mongodb 将upsert与simpleschema一起使用将返回null,而不插入集合

Mongodb 将upsert与simpleschema一起使用将返回null,而不插入集合,mongodb,meteor,simple-schema,Mongodb,Meteor,Simple Schema,嘿,伙计们,我正试着像这样使用Meteor upsert console.log(vendorReviewArr); var updateQuery = {$set: {vendorID: vendorIDVal}, $push: {reviews:vendorReviewArr}}; VendorReviews.upsert( {vendorID: vendorIDVal}, updateQuery, function(error){ console.

嘿,伙计们,我正试着像这样使用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中的集合时未显示任何数据

有谁能帮我解决这个问题吗?感谢阅读。

put console.log(err),这样您就可以准确地看到mongodb的错误throwing@Poorna是的,函数(error){},如上所述,该错误在console.put console.log(err)上返回一个null,这样您就可以确切地看到mongodb是什么错误了throwing@Poorna是的,函数(error){},如上所述,该错误在控制台上返回null。