Answer the question
In order to leave comments, you need to log in
Why is Node returning an empty array from Mongo's collection?
There is a model:
import mongoose from "mongoose";
const Posts = new mongoose.Schema({
title: {type: String, required: true},
description: {type: String, required: true},
text: {type: String, required: true},
image: {type: String}
})
export default mongoose.model("Posts", Posts)
import Posts from '../models/post'
class PostService {
async getAll() {
const post = await Posts.find() // вот тут уже пустой массив приходит: []
return post
}
}
export default new PostService()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question