ในการรับไคลเอ็นต์ที่เชื่อมต่อใน MongoDB ให้ใช้ currentOp() โดยตั้งค่าเป็น true และคุณต้องทำซ้ำชุดผลลัพธ์อาร์เรย์ด้วยความช่วยเหลือของ field client ให้เราใช้ currentOp ก่อน
> db.currentOp(true)
ต่อไปนี้เป็นผลลัพธ์ ที่นี่ไคลเอนต์คือ 127.0.0.1 เนื่องจากเราใช้ localhost ผลลัพธ์จะแสดงไคลเอ็นต์ที่เชื่อมต่อทั้งหมด
{ "inprog" : [ { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "conn1", "connectionId" : 1, "client" : "127.0.0.1:61787", "appName" : "MongoDB Shell", "clientMetadata" : { "application" : { "name" : "MongoDB Shell" }, "driver" : { "name" : "MongoDB Internal Client", "version" : "4.0.5" }, "os" : { "type" : "Windows", "name" : "Microsoft Windows 10", "architecture" : "x86_64", "version" : "10.0 (build 17134)" } }, "active" : true, "currentOpTime" : "2019-03-30T05:13:34.296+0530", "opid" : 12538, "lsid" : { "id" : UUID("da370b0f-093a-45f3-b1fe-697daca8ccd2"), "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=") }, "secs_running" : NumberLong(0), "microsecs_running" : NumberLong(160815), "op" : "command", "ns" : "admin.$cmd.aggregate", "command" : { "currentOp" : 1, "$all" : true, "lsid" : { "id" : UUID("da370b0f-093a-45f3-b1fe-697daca8ccd2") }, "$db" : "admin" }, "numYields" : 0, "locks" : { }, "waitingForLock" : false, "lockStats" : { } }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "LogicalSessionCacheRefresh", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "SessionKiller", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "TTLMonitor", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "free_mon", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "freemon-0", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "startPeriodicThreadToAbortExpiredTransactions", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "WTCheckpointThread", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "ftdc", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "WTJournalFlusher", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "clientcursormon", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "initandlisten", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" } ], "ok" : 1 }