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
}]
});