假设我有这个结构
Account {
Id,
Name,
Password,
Details {
LastSignedIn,
CreatedDate
Address {
City,
Country
}
}
}
Details
子文档属于Account
,Address
子文档属于Details
我mongoose
可以说检索特定的子文档或使用 findqueries 跳过另一个子文档吗?
就像是:
//will return in result 'Account' with only 'DetailsSubdocument' included
Account.findOne({name:'user'}, include: {'Account.DetailsSubdocument'})
//will return in result 'Account' with only 'AddressSubdocument' included
Account.findOne({name:'user'}, include: {'Details.AddressSubdocument'})
//will return in result 'Account' both two subdocuments included
Account.findOne({name:'user'}, include: {'Details.AddressSubdocument', 'Account.DetailsSubdocument'})