CopyPastor

Detecting plagiarism made easy.

Score: 0.8065314233585557; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2020-01-24
by Ashh

Original Post

Original - Posted on 2013-01-20
by Carlos Barcelona



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can use `$split` to split with `+` sign and then `$arrayElemAt` to get the last index.
db.collection.aggregate([ { $project: { value: { $arrayElemAt: [ { $split: [ "$value", "+" ] }, -1 ] } } } ])
You should iterate through. For your specific case:
db.person.find().snapshot().forEach( function (elem) { db.person.update( { _id: elem._id }, { $set: { name: elem.firstname + ' ' + elem.lastname } } ); } );

        
Present in both answers; Present only in the new answer; Present only in the old answer;