const user = await User.aggregate(
[
{"$match":
{ location:
{ $geoWithin:
{ $centerSphere: [ [ -79.7624177, 43.7315479 ], 100/6378.1 ] }
},
}}
])
when call aggregate on my model I got this result:
user: [ { _id: 5fd8de1d3bcb9c8c903c78b5,
books: 5fd8e038ad6c8b8f20d2c88f,
email: ‘user14@test.com’,
firstName: ‘user14’,
password:
‘$2b$10$DSfPujGGoqHMNs6ssbPYuur7s3Jl7lldC6G6C7alVdbA5fioI9dE.’,
location:
{ coordinates: [Array],
_id: 5fd8de1d3bcb9c8c903c78b6,
type: ‘Point’ },
__v: 1 },
{ _id: 5fd8de4d3bcb9c8c903c78b7,
books: 5fd8e091ad6c8b8f20d2c896,
email: ‘user13@test.com’,
firstName: ‘user13’,
password:
‘$2b$10$Je6vICzPUt7U.qCV0DMcT.zS4k.x5rzbg4cTpfBkxZ9/bL8w8u4eq’,
location:
{ coordinates: [Array],
_id: 5fd8de4d3bcb9c8c903c78b8,
type: ‘Point’ },
__v: 2 },
{ _id: 5fd8de4d3bcb9c8c903c78b7,
books: 5fd8e094ad6c8b8f20d2c89b,
email: ‘user13@test.com’,
firstName: ‘user13’,
password:
‘$2b$10$Je6vICzPUt7U.qCV0DMcT.zS4k.x5rzbg4cTpfBkxZ9/bL8w8u4eq’,
location:
{ coordinates: [Array],
_id: 5fd8de4d3bcb9c8c903c78b8,
type: ‘Point’ },
__v: 2 },
{ _id: 5fd8ded13bcb9c8c903c78bb,
books: 5fd8dfc6ad6c8b8f20d2c888,
email: ‘user11@test.com’,
firstName: ‘user11’,
password:
‘$2b$10$qq5WC9oodV82B1UllvWdZ.lZrRMkFsQrxBGn.8mY/uHTcSc4.thrq’,
location:
{ coordinates: [Array],
_id: 5fd8ded13bcb9c8c903c78bc,
type: ‘Point’ },
__v: 1 } ]
I want to filter this also with books properties how can I achieve it?
i tried with $and { books: {$eleMatch: {"title": {$eq: "JavaScript: The Definitive Guide" }} } }
But i am getting empty array.