Loading...

Find ObjectId of the chat room

> db.rooms.find({slug:"elk"}).pretty()
{
        "_id" : ObjectId("59a666cfa9886c002c30b404"),
        "owner" : ObjectId("59a547c2aed276003facf84f"),
        "name" : "Elasticschrott",
        "slug" : "elk",
        "description" : "Everything about the Elasticsearch Universe, including Logstash, Beats",
        "private" : false,
        "lastActive" : ISODate("2017-08-31T08:46:33.690Z"),
        "created" : ISODate("2017-08-30T07:18:39.885Z"),
        "messages" : [ ],
        "participants" : [ ],
        "archived" : true,
        "__v" : 0
}

Find and check messages

> db.messages.find({room:ObjectId("59a666cfa9886c002c30b404")})

Delete all messages of this chat room

> db.messages.deleteMany({room:ObjectId("59a666cfa9886c002c30b404")})
{ "acknowledged" : true, "deletedCount" : 71 }