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
MongoDB 8 · Aggregation
Keep some fields and compute new ones.
db.users.aggregate([
{ $project: { name: 1, domain: { $arrayElemAt: [{ $split: ["$email", "@"] }, 1] } } }
])
Official MongoDB 8 documentation
Was this page helpful?