$ docker pull mongodb/mongodb-community-server:latest latest: Pulling from mongodb/mongodb-community-server Digest: sha256:091fe5a7aaf0ffdda623f1177f6c876312e3815a1622208fd1f01d4a30828f6c Status: Downloaded newer image for mongodb/mongodb-community-server:latest docker.io/mongodb/mongodb-community-server:latest $ docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest 51223da0597a3022f2800974bdb184858428f57a96b7039e15fa8b92eb4c489b $ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 51223da0597a mongodb/mongodb-community-server:latest "python3 /usr/local/…" 23 seconds ago Up 22 seconds 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp mongodb $ docker exec -it 51223da0597a /bin/bash mongodb@51223da0597a:/$ mongosh mongosh ]0;mongosh mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000Current Mongosh Log ID: 68a2cd2f1f487b865189b03c Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.6 Using MongoDB: 8.0.12 Using Mongosh: 2.5.6 For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/ To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy). You can opt-out by running the disableTelemetry() command. ------ The server generated these startup warnings when booting 2025-08-18T06:45:59.000+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem 2025-08-18T06:45:59.325+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted 2025-08-18T06:45:59.325+00:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile 2025-08-18T06:45:59.325+00:00: We suggest setting the contents of sysfsFile to 0. 2025-08-18T06:45:59.325+00:00: Your system has glibc support for rseq built in, which is not yet supported by tcmalloc-google and has critical performance implications. Please set the environment variable GLIBC_TUNABLES=glibc.pthread.rseq=0 2025-08-18T06:45:59.325+00:00: vm.max_map_count is too low ------ test> db.runCommand( { hello: 1 } ) db.runCommand( ... { ... hello: 1 ... } ... ) { isWritablePrimary: true, topologyVersion: { processId: ObjectId('68a2cc26d9152fe4d4d427b6'), counter: Long('0') }, maxBsonObjectSize: 16777216, maxMessageSizeBytes: 48000000, maxWriteBatchSize: 100000, localTime: ISODate('2025-08-18T06:50:47.115Z'), logicalSessionTimeoutMinutes: 30, connectionId: 5, minWireVersion: 0, maxWireVersion: 25, readOnly: false, ok: 1 } test> db.createCollection("test") db.createCollection("test") { ok: 1 } test> db.test.insertMany([ { "id": 1, "foo": 456, "bar": "123" }, { "id": 2, "foo": "123", "bar": 456 }, { "id": 3, "foo": 123, "bar": 456 }, { "id": 4, "foo": "123", "bar": "456" } ]) db.test.insertMany([ ... { ... "id": 1, ... "foo": 456, ... "bar": "123" ... }, ... { ... "id": 2, ... "foo": "123", ... "bar": 456 ... }, ... { ... "id": 3, ... "foo": 123, ... "bar": 456 ... }, ... { ... "id": 4, ... "foo": "123", ... "bar": "456" ... } ... ]) { acknowledged: true, insertedIds: { '0': ObjectId('68a2d1a51f487b865189b03d'), '1': ObjectId('68a2d1a51f487b865189b03e'), '2': ObjectId('68a2d1a51f487b865189b03f'), '3': ObjectId('68a2d1a51f487b865189b040') } } test> db.test.find({"foo": {$gt: 200 }}) db.test.find({"foo": {$gt: 200 }}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' } ] test> db.test.find({"foo": {$gt: "200" }}) db.test.find({"foo": {$gt: "200" }}) test> db.test.find({"bar": {$gt: "200" }}) db.test.find({"bar": {$gt: "200" }}) [ { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' } ] test> db.test.find({$where: function() { return this.bar > this.foo}}) db.test.find({$where: function() { return this.bar > this.foo}}) [ { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' } ] test> db.test.find({$where: "this.bar > this.foo"}) db.test.find({$where: "this.bar > this.foo"}) [ { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' } ] test> db.test.find({$where: "this.foo > this.bar"}) db.test.find({$where: "this.foo > this.bar"}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' } ] test> db.test.insertOne( { "id": 5, "foo": 123, "bar": "abc" } ) db.test.insertOne( ... { ... "id": 5, ... "foo": 123, ... "bar": "abc" ... } ... ) { acknowledged: true, insertedId: ObjectId('68a2d2d81f487b865189b041') } test> db.test.find({$where: "this.foo > this.bar"}) db.test.find({$where: "this.foo > this.bar"}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' } ] test> db.test.find({$where: "this.bar > this.foo"}) db.test.find({$where: "this.bar > this.foo"}) [ { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' } ] test> db.test.insertOne( { "id": 6, "foo": "def", "bar": "abc" } ) db.test.insertOne( ... { ... "id": 6, ... "foo": "def", ... "bar": "abc" ... } ... ) { acknowledged: true, insertedId: ObjectId('68a2d33b1f487b865189b042') } test> db.test.find({$where: "this.bar > this.foo"}) db.test.find({$where: "this.bar > this.foo"}) [ { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' } ] test> db.test.find({$where: "this.foo > this.bar"}) db.test.find({$where: "this.foo > this.bar"}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' }, { _id: ObjectId('68a2d33b1f487b865189b042'), id: 6, foo: 'def', bar: 'abc' } ] test> db.test.find({$expr: {$gt: ["this.foo", "this.bar"]}}) db.test.find({$expr: {$gt: ["this.foo", "this.bar"]}}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' }, { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' }, { _id: ObjectId('68a2d2d81f487b865189b041'), id: 5, foo: 123, bar: 'abc' }, { _id: ObjectId('68a2d33b1f487b865189b042'), id: 6, foo: 'def', bar: 'abc' } ] test> db.test.find({$expr: {$gt: ["$foo", "$bar"]}}) db.test.find({$expr: {$gt: ["$foo", "$bar"]}}) [ { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d33b1f487b865189b042'), id: 6, foo: 'def', bar: 'abc' } ] test> db.test.find({$expr: {$gt: ["$bar", "$foo"]}}) db.test.find({$expr: {$gt: ["$bar", "$foo"]}}) [ { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' }, { _id: ObjectId('68a2d2d81f487b865189b041'), id: 5, foo: 123, bar: 'abc' } ] test> db.test.find({sortBy: {foo: 1}}) db.test.find({sortBy: {foo: 1}}) test> db.test.find().sort({foo:-1}) db.test.find().sort({foo:-1}) [ { _id: ObjectId('68a2d33b1f487b865189b042'), id: 6, foo: 'def', bar: 'abc' }, { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' }, { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 }, { _id: ObjectId('68a2d2d81f487b865189b041'), id: 5, foo: 123, bar: 'abc' } ] test> db.test.find().sort({bar:-1}) db.test.find().sort({bar:-1}) [ { _id: ObjectId('68a2d2d81f487b865189b041'), id: 5, foo: 123, bar: 'abc' }, { _id: ObjectId('68a2d33b1f487b865189b042'), id: 6, foo: 'def', bar: 'abc' }, { _id: ObjectId('68a2d1a51f487b865189b040'), id: 4, foo: '123', bar: '456' }, { _id: ObjectId('68a2d1a51f487b865189b03d'), id: 1, foo: 456, bar: '123' }, { _id: ObjectId('68a2d1a51f487b865189b03e'), id: 2, foo: '123', bar: 456 }, { _id: ObjectId('68a2d1a51f487b865189b03f'), id: 3, foo: 123, bar: 456 } ] test>