Database
db={"toko":[{"_id":ObjectId("5f1d77aca53cb13980324c73"),"listMerek":[],"follower":[ObjectId("5f3441ff04431c517b176d11")],"etalase":[ObjectId("5f1fd05128915e3d69c2a124"),ObjectId("5f1fd15928915e3d69c2a126")],"approve":2,"populer":false,"password":"$2a$10$WFRaAcIxEhHOw2c3y.Y4zORNF9Z2lpyBQinJ9l3ULq2vbwJdSzmzi","merek":"coba1","alamat":"Jl. Kita Masih Panjang 2020","whatsapp":"81333432070","instagram":"andre_pp_","email":"coba1","fotoktp":"2020-07-26T12-31-39.738Zsara.jpg","banner":[{"_id":ObjectId("5f37913f75414f35dc0e450d"),"gambar":"2020-08-15T07-39-43.116Zefg.png"},{"_id":ObjectId("5f37920375414f35dc0e450e"),"gambar":"2020-08-15T07-42-59.562Zcomps.jpg"}],"produk":[{"foto_produk":["2020-08-12T18-29-54.504Zkemeja1.jpg"],"_id":ObjectId("5f343522301c3e33868271d3"),"nama_produk":"Baju","etalase":ObjectId("5f1fd05128915e3d69c2a124"),"jenis":ObjectId("5f1fd06a28915e3d69c2a125"),"bahan":"Katun","warna":"Merah","harga":75000,"link_bukalapak":"asd","link_shopee":"asd","link_tokopedia":"asd","deskripsi":"Kemeja Keren","updatedAt":ISODate("2020-08-12T18:29:54.510Z"),"createdAt":ISODate("2020-08-12T18:29:54.510Z")},{"foto_produk":["2020-08-12T18-37-31.352Zcelana1.jpg"],"_id":ObjectId("5f3436eb6be3b63930f1338e"),"nama_produk":"Katok Bolong","etalase":ObjectId("5f1fd15928915e3d69c2a126"),"jenis":ObjectId("5f1fd18028915e3d69c2a127"),"bahan":"Katun","warna":"Biru","harga":99000,"link_bukalapak":"asd","link_shopee":"asd","link_tokopedia":"asd","deskripsi":"Katok Gaul","updatedAt":ISODate("2020-08-12T18:37:31.358Z"),"createdAt":ISODate("2020-08-12T18:37:31.358Z")},{"foto_produk":["2020-08-15T08-22-18.977Zkaos.jpg"],"_id":ObjectId("5f379b3a75414f35dc0e450f"),"nama_produk":"Kaos Polos","etalase":ObjectId("5f1fd05128915e3d69c2a124"),"jenis":ObjectId("5f1fd23628915e3d69c2a12a"),"bahan":"Katun","warna":"Merah","harga":36000,"link_bukalapak":"asd","link_shopee":"asd","link_tokopedia":"asd","deskripsi":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.","updatedAt":ISODate("2020-08-15T08:22:18.979Z"),"createdAt":ISODate("2020-08-15T08:22:18.979Z")},{"foto_produk":["2020-08-15T08-30-06.432Zkemeja1.jpg"],"_id":ObjectId("5f379d0e75414f35dc0e4510"),"nama_produk":"Kemeja Terbaik Di Dunia","etalase":ObjectId("5f1fd05128915e3d69c2a124"),"jenis":ObjectId("5f1fd23628915e3d69c2a12a"),"bahan":"Katun","warna":"Merah","harga":36000,"link_bukalapak":"","link_shopee":"","link_tokopedia":"","deskripsi":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.","updatedAt":ISODate("2020-08-15T08:30:06.433Z"),"createdAt":ISODate("2020-08-15T08:30:06.433Z")},{"foto_produk":["2020-08-15T08-38-07.018Zasd.jpg"],"_id":ObjectId("5f379eef75414f35dc0e4511"),"nama_produk":"Longsleeve Polos","etalase":ObjectId("5f1fd05128915e3d69c2a124"),"jenis":ObjectId("5f1fd23628915e3d69c2a12a"),"bahan":"Katun","warna":"Biru","harga":55000,"link_bukalapak":"","link_shopee":"","link_tokopedia":"","deskripsi":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.","updatedAt":ISODate("2020-08-15T08:38:07.019Z"),"createdAt":ISODate("2020-08-15T08:38:07.019Z")}],"createdAt":ISODate("2020-07-26T12:31:40.435Z"),"updatedAt":ISODate("2020-08-15T11:32:00.607Z"),"__v":0,"bukalapak":"null","deskripsi":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua","shopee":"null","tokopedia":"ahha-official","username":"null","website":"https://www.w3schools.com/","foto_profil":"2020-08-07T14-26-12.042Ztom.jpg"}],"kategoris":[{"_id":ObjectId("5f1fd05128915e3d69c2a124"),"label":"Baju","gambar":"2020-07-28T07-14-21.672Zbaju.png","jenis":[{"_id":ObjectId("5f1fd06a28915e3d69c2a125"),"label":"Kemeja","gambar":"2020-07-28T07-14-47.792ZIcons_kemeja.png","updatedAt":ISODate("2020-07-28T07:14:50.803Z"),"createdAt":ISODate("2020-07-28T07:14:50.803Z")},{"_id":ObjectId("5f1fd1ce28915e3d69c2a128"),"label":"Polo","gambar":"2020-07-28T07-20-44.622ZIcons_polo.png","updatedAt":ISODate("2020-07-28T07:20:46.016Z"),"createdAt":ISODate("2020-07-28T07:20:46.016Z")},{"_id":ObjectId("5f1fd1ff28915e3d69c2a129"),"label":"Long Sleeve","gambar":"2020-07-28T07-21-34.018ZIcons_t-shirt long sleeve.png","updatedAt":ISODate("2020-07-28T07:21:35.879Z"),"createdAt":ISODate("2020-07-28T07:21:35.879Z")},{"_id":ObjectId("5f1fd23628915e3d69c2a12a"),"label":"Short Sleeve","gambar":"2020-07-28T07-22-29.845ZIcons_t-shirt short sleeve.png","updatedAt":ISODate("2020-07-28T07:22:30.997Z"),"createdAt":ISODate("2020-07-28T07:22:30.997Z")}],"createdAt":ISODate("2020-07-28T07:14:25.526Z"),"updatedAt":ISODate("2020-07-28T07:22:30.997Z"),"__v":0},{"_id":ObjectId("5f1fd15928915e3d69c2a126"),"label":"Celana","gambar":"2020-07-28T07-18-46.759Zcelana.png","jenis":[{"_id":ObjectId("5f1fd18028915e3d69c2a127"),"label":"Casual","gambar":"2020-07-28T07-19-26.335ZIcons_casual.png","updatedAt":ISODate("2020-07-28T07:19:28.990Z"),"createdAt":ISODate("2020-07-28T07:19:28.990Z")},{"_id":ObjectId("5f1fd2ae28915e3d69c2a12b"),"label":"Short","gambar":"2020-07-28T07-24-29.283ZIcons_short.png","updatedAt":ISODate("2020-07-28T07:24:30.367Z"),"createdAt":ISODate("2020-07-28T07:24:30.367Z")},{"_id":ObjectId("5f1fd37c28915e3d69c2a131"),"label":"Sport","gambar":"2020-07-28T07-27-54.546ZIcons_sport.png","updatedAt":ISODate("2020-07-28T07:27:56.118Z"),"createdAt":ISODate("2020-07-28T07:27:56.118Z")}],"createdAt":ISODate("2020-07-28T07:18:49.799Z"),"updatedAt":ISODate("2020-07-28T07:27:56.118Z"),"__v":0},{"_id":ObjectId("5f1fd2c228915e3d69c2a12c"),"label":"Luaran","gambar":"2020-07-28T07-24-48.124Zluaran.png","jenis":[{"_id":ObjectId("5f1fd35028915e3d69c2a12e"),"label":"Bomber","gambar":"2020-07-28T07-27-09.584ZIcons_bomber.png","updatedAt":ISODate("2020-07-28T07:27:12.734Z"),"createdAt":ISODate("2020-07-28T07:27:12.734Z")},{"_id":ObjectId("5f1fd36e28915e3d69c2a130"),"label":"Denim","gambar":"2020-07-28T07-27-40.526ZIcons_denim.png","updatedAt":ISODate("2020-07-28T07:27:42.315Z"),"createdAt":ISODate("2020-07-28T07:27:42.315Z")}],"createdAt":ISODate("2020-07-28T07:24:50.128Z"),"updatedAt":ISODate("2020-07-28T14:27:07.907Z"),"__v":0},{"_id":ObjectId("5f1fd2e628915e3d69c2a12d"),"label":"Sepatu","gambar":"2020-07-28T07-25-23.351Zsepatu.png","jenis":[{"_id":ObjectId("5f1fd38a28915e3d69c2a132"),"label":"Kulit","gambar":"2020-07-28T07-28-08.829ZIcons_kulit.png","updatedAt":ISODate("2020-07-28T07:28:10.124Z"),"createdAt":ISODate("2020-07-28T07:28:10.124Z")},{"_id":ObjectId("5f1fd39728915e3d69c2a133"),"label":"Sneaker","gambar":"2020-07-28T07-28-21.161ZIcons_sneaker.png","updatedAt":ISODate("2020-07-28T07:28:23.453Z"),"createdAt":ISODate("2020-07-28T07:28:23.453Z")}],"createdAt":ISODate("2020-07-28T07:25:26.220Z"),"updatedAt":ISODate("2020-07-28T07:28:23.453Z"),"__v":0}]}
Query
db.toko.aggregate([{$match:{_id:ObjectId("5f1d77aca53cb13980324c73")}},{$unwind:"$produk"},{$lookup:{from:"kategoris",as:"produk.jenisnya",let:{pjid:"$produk.jenis"},pipeline:[{$unwind:"$jenis"},{$match:{$expr:{$eq:["$$pjid","$jenis._id"]}}},{$project:{"jenis._id":1,"jenis.label":1}}]}},{$unwind:{path:"$produk.jenisnya"}},{$group:{_id:{_id:"$_id",produk_id:"$produk._id"},root:{$first:"$$ROOT"}}},{$replaceRoot:{newRoot:{$mergeObjects:[{foto_profil:"$root.foto_profil"},"$root.produk"]}}},{$skip:0},{$limit:10}])