Answer the question
In order to leave comments, you need to log in
How to check if the id is in the array during the request?
For example, there is a Room, Message and User model.
Schema Message = {
title: { type: Schema.Types.String, require: true },
room: { type: Schema.Types.ObjectId, ref: "User" },
user: { type: Schema.Types.ObjectId, ref: "User" },
hideForUsers: [{ type: Schema.Types.ObjectId, ref: "User" }],
}
MessageModel.find({ room: roomId});
Answer the question
In order to leave comments, you need to log in
Not this?
MessageModel.find({
room: roomId,
hideForUsers: { $nin: [ UserId ] }
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question