Я создал схему mongoose для поиска документа в MongoDB, но она не работает, всегда возвращает пустой массив
В MongoDB у меня есть коллекция с такими документами
{
"_id":"5cba6a9079beee20a817b532",
"name":"Soborniy, 151",
"imageURL":"http://localhost:3001/locations/zaporozhya_soborniy_151.jpg",
"lat":47.845174,
"lng":35.127215,
"mainImageURL":"http://localhost:3001/points/Zaporozhya_Soborniy_151.jpg",
"pointName":"Jays Zaporizhia: Soborniy 151",
"pointDescription":"This is our European flagship store. For this store we chose an area called Kreuzber, a multicultural melting pot of artists, hipsters and all things Berlin. In this vast 150m² open space, we showed our respect to the greats of German design by creating a shop interior in the style of iconic Braun designer Dieter Rams. Our seating area, bean cellar, shop counter are all a homage to his amazing craft and ingenuity. The store also has a large kitchen, which is a new challenge for our brand. We hired two young chefs, Tyler from America, and Paulo from Italy, to cook locally grown, fresh, simple and healthy breakfast and lunch menu. As for coffee, %Arabica Berlin is filled with our usual passion for serving the best beans with the upmost dedication. Our founder, Kenneth owns a coffee farm in Hawaii, and we trade green beans from all over the world. We even offer beans from Ninety Plus Coffee, who are creating barista champions in so many countries the world over. This store is filled with our passion for coffee, food, design, and seeing the world. Please visit us and let’s ”See the World Through Coffee” together",
"neighborhoodPoints":[
{
"_id":"5cba6e034ca43420a82f7313",
"name":"Soborniy, 172",
"imageURL":"http://localhost:3001/locations/zaporozhya_soborniy_172.jpg"
},
{
"_id":"5cba6ec54ca43420a82f7314",
"name":"Soborniy, 175",
"imageURL":"http://localhost:3001/locations/zaporozhya_soborniy_175.jpg"
}
]
}
Создана схема Мангуста для получения документов из коллекции
var mongoose = require("mongoose");
const locationSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
name: String,
imageURL: String,
lat: Number,
lng: Number,
mainImageURL: String,
pointName: String,
pointDescription: String,
neighborhoodPoints: [
{
_id: mongoose.Schema.Types.ObjectId,
name: String,
imageURL: String,
},
],
});
const Location = mongoose.model("location", locationSchema, "locations");
module.exports = Location;
И Экспресс-маршрутизатор для обработки запроса
const express = require("express");
const router = express.Router();
const Location = require("../models/location_schema");
router.get("/", (req, res) => {
Location.find().exec((err, locations) => {
if (err) return res.status(500).json(err);
res.status(200).json(locations);
});
});
module.exports = router;
Почему мой маршрут возвращает это?
[]