MongoDB 8 · Aggregation

Reshape documents

Keep some fields and compute new ones.

db.users.aggregate([
  { $project: { name: 1, domain: { $arrayElemAt: [{ $split: ["$email", "@"] }, 1] } } }
])

Official MongoDB 8 documentation

More aggregation commands

All aggregation commands · MongoDB 8 cheatsheet

Was this page helpful?