sdelements / lets-chat

Self-hosted chat app for small teams
http://sdelements.github.io/lets-chat
MIT License
9.76k stars 1.58k forks source link

Can't join a private room, if use mongodb v3.6.4 #782

Closed qvjp closed 6 years ago

qvjp commented 6 years ago

mongo error: MongoError: Unknown modifier: $pushAll.

You can add one line to app/models/room.js to solve this problem.

var RoomSchema = new mongoose.Schema({
    slug: {
        type: String,
        required: true,
        trim: true,
        lowercase: true,
        unique: true,
        match: /^[a-z0-9_-]+$/i
    },
    archived: {
        type: Boolean,
        default: false
    },
    name: {
        type: String,
        required: true,
        trim: true
    },
    description: {
        type: String,
        trim: true
    },
    owner: {
        type: ObjectId,
        ref: 'User',
        required: true
    },
    participants: [{ // We can have an array per role
        type: ObjectId,
        ref: 'User'
    }],
    messages: [{
        type: ObjectId,
        ref: 'Message'
    }],
    created: {
        type: Date,
        default: Date.now
    },
    lastActive: {
        type: Date,
        default: Date.now
    },
    private: {
        type: Boolean,
        default: false
    },
    password: {
        type: String,
        required: false//only for password-protected room
    }
},{
    usePushEach: true // *****Here*****
});