问题描述
我有这样的 eventSchema,我需要在每个事件中找到“用户已经注册了这个事件”
const EventSchema = new Schema({
eventName: {
type: String,},eventDate: {
type: Date,registerUser: [
{
user: {
type: Schema.Types.ObjectId,ref: 'user',name: {
type: String,phoneNumber: {
type: String,],})
我尝试这个查询来检查路线
'/joinEvent/:event_id'
const checkJoined = Event.findOne({$and:[{_id: req.params.event_id},{'registerUser.user': req.user.id }]})
此功能适用于在 eventSchema 中注册的每个用户的 POST,但在我检查用户是否已注册该事件时不起作用
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)