1

I'm trying to remove a document from an array threads that is a field in the collection's head document.

In Mongodb console I write following query:

db.inboxes.update({}, { $pull: {threads: {"_id":ObjectId(”5550b41ce7c33013c8000006”)}}})

But I keep getting:

Unexpected token ILLEGAL

It's driving me crazy. The Collection's schema is as following:

var inboxSchema = mongoose.Schema({
    user: {
        type: mongoose.Schema.ObjectId,
        ref: 'userSchema',
        required: true
    },
    threads: [{
        name: String,
        guid: String,
        with: {
            _id: {
                type: mongoose.Schema.ObjectId,
                ref: 'userSchema'
            },
            name: {
                username: String,
                firstname: String,
                lastname: String
            },
            email: {
                type: String,
                match: /\S+@\S+\.\S+/
            }
        },
        messages: [{
            heading: String,
            sent: {
                type: Date,
                default: Date.now
            },
            from: {
                type: mongoose.Schema.ObjectId,
                ref: 'userSchema'
            },
            to: {
                type: mongoose.Schema.ObjectId,
                ref: 'userSchema'
            },
            body: String
        }],
        updated: {
            type: Date,
            default: Date.now
        },
        unreadMessage: Boolean
    }]
});
Neo-coder
  • 7,715
  • 4
  • 33
  • 52

1 Answers1

1

Take a look at your query

db.inboxes.update({}, { $pull: {threads: {"_id":ObjectId(”5550b41ce7c33013c8000006”)}}})

in ObjectId argument you have wrong quote marks instead of ". Replace them and you will get rid of the error :)

bagrat
  • 7,158
  • 6
  • 29
  • 47