FIND SPECIFIC FIELDS FROM SunDOCUMENTS OF ALL DOCUMENTS UNDER A COLLECTION IN MONGODB
db.inventory.find( { item: /^j/ }, { 'size.h': 1 } )
FIND SPECIFIC FIELDS FROM SunDOCUMENTS OF ALL DOCUMENTS UNDER A COLLECTION IN MONGODB
db.inventory.find( { item: /^j/ }, { 'size.h': 1 } )
FIND SPECIFIC FIELDS FROM SunDOCUMENTS OF ALL DOCUMENTS UNDER A COLLECTION IN MONGODB
//use when you want `_id,size` (As object) with its only property `h` in
//$project,
db.inventory.aggregate([{$match:{ item: /^j/ } },{ $project:{
"size.h":"$size.h" } }])
//use when you want `_id,size` size ase whole object
//$project,
db.inventory.aggregate([{$match:{ item: /^j/ } },{ $project:{ "size":1 }
}])
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us