Wednesday, 3 May 2017

How to add new data to current string in MongoDB?

For example I have some data in my DB

{
    id: 1
    name: "foo"
}

And I wish to add some string to my current. So how to add string to my current string in database? I tried:

Cat.findOneAndUpdate({id: 1}, {$set:{name: +"bar"}}, function(err, doc){
    if(err){
        console.log("Something wrong when updating data!");
    }
    console.log(doc);
});

But it isn't working...



via Bim Bam

No comments:

Post a Comment