Ошибка типа: POINT.find не является функцией Мангуста - PullRequest
1 голос
/ 25 апреля 2020
TypeError: Point.find is not a function
    at /Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/routes/api.js:10:11
    at Layer.handle [as handle_request] (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/layer.js:95:5)
    at /Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:174:3)
    at router (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:317:13)
    at /Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:275:10)
    at /Users/milan/MILAN/react-hand-maridian/react-hand-meridian/exp/node_modules/express/lib/router/index.js:635:15

Придерживаясь этой ошибки при выполнении Model.find () для mon goose, каждое из объявлений выглядит хорошо. База данных в пн go Атлас point

  • Эксп
    • / модели
      • point.model.js
    • / маршруты
      • api.js
    • server.js

point.model. js

const mongoose = require("mongoose");

const pointSchema = new mongoose.Schema({
    name: {
        type: String,
        unique: true,
        required: true,
    },
    meridianGroup: {
        type: String,
        required: true,
    },
    sideFacing: { 
        type: String, 
        required: true,
    },
    rightHand: {
        type: Object,
        offX: { 
            type: Number, 
            required: true,
        },
        offY: { 
            type: Number, 
            required: true,
        },
    },
    leftHand: {
        type: Object,
        offX: { 
            type: Number, 
            required: true,
        },
        offY: { 
            type: Number, 
            required: true,
        },
    },
});

module.export = mongoose.model("point", pointSchema);

API. js

const router = require("express").Router();
const Point = require("../models/point.model");

// This are are API routes

// Get all points
router.route('/points').get((req, res)=>{
    console.log(Point)
    // res.send("all points")
    Point.find()
        .then(points => res.json(points))
        .catch(err => res.status(400).json(err))
});

module.exports = router;
...