Skip to content

Instantly share code, notes, and snippets.

@estan
Created October 19, 2024 07:58
Show Gist options
  • Save estan/8d251d3e252dee98d4361f48f10100d2 to your computer and use it in GitHub Desktop.
Save estan/8d251d3e252dee98d4361f48f10100d2 to your computer and use it in GitHub Desktop.
{{{"_id":{"$oid":"63401fc4859babfd692de2da"},"a":{"b":"a"},"a":{}}}}
estan@newton:~$ docker run -p 27017:27017 -d mongo:8.0.1
Unable to find image 'mongo:8.0.1' locally
8.0.1: Pulling from library/mongo
Digest: sha256:9342a9279a9841fc5f8192e49dcaaf9404e6bb3a90e8cf134eb96074830dd448
Status: Downloaded newer image for mongo:8.0.1
f72d88d2cadb2fe59f8da17c981ea70b075fbba482ccd544ce38606c67f553b7
estan@newton:~$ echo '[{"_id":{"$oid":"63401fc4859babfd692de2da"},"a":{"b":"a"},"a":{}}]' | mongoimport -h localhost -d testdb -c testcol --jsonArray
2024-10-18T14:13:30.002+0200 connected to: mongodb://localhost/
2024-10-18T14:13:30.051+0200 1 document(s) imported successfully. 0 document(s) failed to import.
estan@newton:~$ mongosh localhost/testdb --eval 'db.getCollection("testcol").find({"a.b":{$exists:true}})'
[ { _id: ObjectId('63401fc4859babfd692de2da'), a: {} } ]
estan@newton:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment