1

Have a collection with values

_id:ObjectId('......')
ton_id :ObjectId('abcd')
value:qwejc+iejtns/@
date:2019-12-13T07:09:40.075+00:00


_id:ObjectId('......')
ton_id :ObjectId('abcd')
value:asdf+kine
date:2018-1-13T07:09:40.075+00:00

Need a required output :

grab data after +

_id:ObjectId('......')
ton_id :ObjectId('abcd')
value:iejtns/@
date:2019-12-13T07:09:40.075+00:00


_id:ObjectId('......')
ton_id :ObjectId('abcd')
value:kine
date:2018-1-13T07:09:40.075+00:00

1 Answer 1

1

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]
    }
  }}
])

MongoPlayground

Sign up to request clarification or add additional context in comments.

Comments

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.