Skip to content

Instantly share code, notes, and snippets.

@sezRR
Created February 27, 2022 21:00
Show Gist options
  • Save sezRR/bd568660235ee5582e2af9d6d8821f83 to your computer and use it in GitHub Desktop.
Save sezRR/bd568660235ee5582e2af9d6d8821f83 to your computer and use it in GitHub Desktop.
MongoDB Aggregate for DTO
db.Todos.aggregate([
{
$lookup: {
from: "Tags",
localField: "tags.$id",
foreignField : "_id",
as: "tags"
}
},
{
$project: {
"tags._id":0,
"tags._class":0,
"tags.isActive":0,
"tags.createdAt":0
}
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment