0

i am trying to push array in document array my collection is

{
"_id": "58eed81af6f8e3788de703f9",
"first_name": "abc",
"vehicles": {
    "exhibit": "18",
    "title": "Motor Velicle Information for Donald French",
    "details": [
        {
            "year": "",
            "make_model": "",
            "registered_owner": "",
            "license_number": "",
            "date_of_purchase": "",
            "purchase_price": ""
        }
    ]
}

}

so what i want is to push data in details for that i had try like this

 Licensee.update({"_id":"58eed81af6f8e3788de703f9"},{
        $push:{
            "vehicles.details":data
        }
    },function(err,data){
        if(!err)
        {
            console.log('data',data);
        }
        else
        {
            console.log('err',err);
        }
    });

and for this i create one schema i don't know is right or not

var licSchema = new SimpleSchema({
"_id":{
    type:String,
    label:"_id",
    optional: false,
},
"vehicles.details.year": {
    type: String,
    label: "year",
    optional: true,
},
"vehicles.details.make_model": {
    type: String,
    label: "make_model",
    optional: true,
}

});

where is my fault please give me solution . Error Uncaught Error: After filtering out keys not in the schema, your modifier is now empty

2
  • Whats the error message here Commented Apr 22, 2017 at 8:17
  • Uncaught Error: After filtering out keys not in the schema, your modifier is now empty Commented Apr 22, 2017 at 8:22

1 Answer 1

1

You can try this. AddToSet should be the right way.

const schema = new SimpleSchema({
    "vehicles.details.$.year": {
        type: String,
        label: "year",
        optional: true,
     },
    "vehicles.details.$.make_model": {
        type: String,
        label: "make_model",
        optional: true,
     }
 });

Licensee.update({"_id":"58eed81af6f8e3788de703f9"},{
    $addToSet:{
        "vehicles.details": data
    }
});
Sign up to request clarification or add additional context in comments.

3 Comments

same Error i thing i fault is in Schema.
can you check my schema
@kumbhaniBhavesh ya you're right. Check the updated answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.