Express Api problem

Hello all,
I am trying to fetch posts from particular user who is logged in. the post cannot be seen by other user who is not logged in and also who is not the same user.

I used

router.get('/',(req,res)=>{
    Post.find({})
    .sort({date:-1}).exec()
    .then(posts=>res.json(posts))
    .catch(err=>res.status(400).json(err))
});

and in Post model,

const PostSchema = new Schema({
    user:{
        type:Schema.Types.ObjectId,
        ref:'users'
    },
    title:{
        type:String,
        required:true
    },
    description:{
        type:String,
        required:true
    },
    date:{
        type:Date,
        default:Date.now
    }
});

How exactly are you authenticating your users? Without knowing this it will be hard to help you. In any case a common way of doing this is to first authenticate the user using middleware, then populate the request object with the user _id and/or some other user information. You can use this middleware before any routes that require authentication. You can get posts that belong to the currently authenticated user by querying the “user” field with the user’s ID.