Here is my mongo database
db.employee.insert(
{
_id: 'shop2',
ShopName: 'Gala',
ShopAddress: 'Kilmeaden',
Owner: 'Bryan Power',
ShopContactNumber: '08766442365',
Employee: [
{
EmployId: '4',
EmployName: 'Adam Byrne',
EmployContactNumber: 08688972,
EmployAddress: 'Bawnfune',
Salary: 250.00,
Hours: 25,
Wage: 9.00,
EmployeeType: 'FloorStaff'
},
{
EmployId: '5',
EmployName: 'Shane Power',
EmployContactNumber: 0873347584,
EmployAddress: 'Portlaw',
Salary: 350.00,
Hours: 32,
PayType: 'Bank',
Wage: 8.65,
EmployeeType: 'FloorStaff'
},
{
EmployId: '6',
EmployName: 'Jackie Legs',
EmployContactNumber: 0861231237,
EmployAddress: 'Ballyduff',
Salary: 550.00,
Hours: 32,
PayType: 'Cheque',
Wage: 11.60,
EmployeeType: 'Manager'
}
]});
I am trying to access the sub document of this insert statement to retrieve the EmployName, Salary and hours. Here is what I have been trying to do but it returns all three sub documents instead. Can I isolate these particular values?
db.employee.find({"Employee.EmployId": ""},
{
"Employee.EmployName":"Adam Byrne",
"Employee.Salary": 250.00,
"Employee.Hours":25
}).pretty();