У меня есть VisitModel, которая сохранила посещение различных пользователей в разных местах посетителей.
{
"_id" : ObjectId("5bb5d748b8c8a07fee6b4437"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(500),
"hrno" : NumberInt(200900410),
"lastUpdationTime" : ISODate("2018-10-04T09:03:04.619+0000"),
"mobileNo" : "9413394574",
"name" : "Hirdesh Sharma",
"simInventory" : NumberInt(10),
"ssa" : "cojp",
"visitedRetailer" : "7597000662",
"visitLocation" : {
"lat" : "26.9140156",
"lng" : "75.7997062"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb5ea682b955e0961e55b24"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(10),
"hrno" : NumberInt(200900410),
"lastUpdationTime" : ISODate("2018-10-04T10:24:40.180+0000"),
"mobileNo" : "9413394574",
"name" : "Hirdesh Sharma",
"simInventory" : NumberInt(10),
"ssa" : "cojp",
"visitedRetailer" : "7597000662",
"visitLocation" : {
"lat" : "26.9140203",
"lng" : "75.7997103"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb71766edeebb1682902c5a"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(0),
"hrno" : NumberInt(200900410),
"lastUpdationTime" : ISODate("2018-10-05T07:48:54.566+0000"),
"mobileNo" : "9413394574",
"name" : "Hirdesh Sharma",
"simInventory" : NumberInt(0),
"ssa" : "cojp",
"visitedRetailer" : "123456789",
"visitLocation" : {
"lat" : "26.913970499999998",
"lng" : "75.799515"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb71991edeebb1682902c5b"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(0),
"hrno" : NumberInt(200900410),
"lastUpdationTime" : ISODate("2018-10-05T07:58:09.241+0000"),
"mobileNo" : "9413394574",
"name" : "Hirdesh Sharma",
"simInventory" : NumberInt(0),
"ssa" : "cojp",
"visitedRetailer" : "1234567890",
"visitLocation" : {
"lat" : "26.9140163",
"lng" : "75.7997024"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb72c28edeebb1682902c5d"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(10000),
"hrno" : NumberInt(200901869),
"lastUpdationTime" : ISODate("2018-10-05T09:17:28.825+0000"),
"mobileNo" : "9413395846",
"name" : "Dharmendra Soni",
"simInventory" : NumberInt(15),
"ssa" : "Circle Office",
"visitedRetailer" : "0000000000",
"visitLocation" : {
"lat" : "26.8922714",
"lng" : "75.8042042"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb72e50edeebb1682902c5e"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(5000),
"hrno" : NumberInt(200901869),
"lastUpdationTime" : ISODate("2018-10-05T09:26:40.371+0000"),
"mobileNo" : "9413395846",
"name" : "Dharmendra Soni",
"simInventory" : NumberInt(10),
"ssa" : "Circle Office",
"visitedRetailer" : "9414002070",
"visitLocation" : {
"lat" : "26.8922503",
"lng" : "75.8041773"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb72f49edeebb1682902c5f"),
"__v" : NumberInt(0),
"ctopamount" : 1.5,
"hrno" : NumberInt(200901869),
"lastUpdationTime" : ISODate("2018-10-05T09:30:49.843+0000"),
"mobileNo" : "9413395846",
"name" : "Dharmendra Soni",
"simInventory" : null,
"ssa" : "Circle Office",
"visitedRetailer" : "7597000559",
"visitLocation" : {
"lat" : "26.8922608",
"lng" : "75.8041638"
}
}
// ----------------------------------------------
{
"_id" : ObjectId("5bb759e7edeebb1682902c63"),
"__v" : NumberInt(0),
"ctopamount" : NumberInt(0),
"hrno" : NumberInt(198911286),
"lastUpdationTime" : ISODate("2018-10-05T12:32:39.394+0000"),
"mobileNo" : "9413395614",
"name" : "Shankara lal meena",
"simInventory" : NumberInt(0),
"ssa" : "Chittorgarh",
"visitedRetailer" : "7597000559",
"visitLocation" : {
"lat" : "24.038592",
"lng" : "74.7767928"
}
}
}
У меня есть другая модель, в которой есть сохраненная база данных RetailerLocation, в которой сохранено имя зарегистрированного розничного продавца, адрес, номер розничного продавца и местоположение
{
"_id" : ObjectId("5c864a80498ceb2d94a8a029"),
"Name of Retailer" : "Karan Singh",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.8122376,
"lng" : 75.7783984
},
"Retailernumber" : "7597000559"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02a"),
"Name of Retailer" : "HANUMAN PRASAD",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9142872,
"lng" : 75.7431824
},
"Retailernumber" : "7597000632"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02b"),
"Name of Retailer" : "Karan Singh",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9039945,
"lng" : 75.8325143
},
"Retailernumber" : "7597000633"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02c"),
"Name of Retailer" : "kunal hemani",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.931319,
"lng" : 75.8201112
},
"Retailernumber" : "7597000638"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02d"),
"Name of Retailer" : "kumawat floor mill",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.8592253,
"lng" : 75.7851659
},
"Retailernumber": "7597000662"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02e"),
"Name of Retailer" : "care point",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9247296,
"lng" : 75.7894896
},
"Retailernumber" : "7597000708"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a02f"),
"Name of Retailer" : "SAYED MOBILE",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.933338,
"lng" : 75.8074372
},
"Retailernumber" : "7597000718"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a030"),
"Name of Retailer" : "jaipur moters",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9187819,
"lng" : 75.8102266
},
"Retailernumber" : "7597000773"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a031"),
"Name of Retailer" : "sona telecom",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9212756,
"lng" : 75.8085795
},
"Retailernumber" : "7597000776"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a032"),
"Name of Retailer" : "sangam mobile",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.9194859,
"lng" : 75.8078163
},
"Retailernumber" : "7597000785"
}
// ----------------------------------------------
{
"_id" : ObjectId("5c864a80498ceb2d94a8a033"),
"Name of Retailer" : "bombay collection",
"SSA" : "JAIPUR",
"savedLocation" : {
"lat" : 26.8564543,
"lng" : 75.8207683
},
"Retailernumber": "7597000792"
}
теперь я хочу отобразить данные следующим образом
{
"ctopamount" : NumberInt(500),
"hrno" : NumberInt(200900410),
"mobileNo" : "9413394574",
"name" : "Hirdesh Sharma",
"simInventory" : NumberInt(10),
"ssa" : "cojp",
"visitedRetailer" : "7597000662",
"visitLocation" : {
"lat" : "26.9140156",
"lng" : "75.7997062"
}
"savedLocation" : {
"lat" : "26.9140156",
"lng" : "75.7997062"
}
}
где сохраненное местоположение должно быть выбрано из коллекции RetailerLocation на основе visitedRetailer=RetailerMobile