i have a problem with calculate distance.
i have data in database like this :
in there, i'am using mongodb. and i using package geolib to get calculate distance. when i calculate the distance, it always get null, but when the field longitude and latitude, i set manual value, it get the value.
CampModel.aggregate([
{
$addFields: {
longitude: {
$arrayElemAt: ['$longlat', 0],
},
latitude: {
$arrayElemAt: ['$longlat', 1],
},
distance: getDistance(
{
longitude: -6.139236985993344,
latitude: 106.73070885735316,
},
{
longitude: '$longitude',
latitude: '$latitude',
},
),
},
},
{
$project: {
createdAt: '$createdAt',
distance: '$distance',
},
},
]);
thank you.