@@ -228,8 +228,8 @@ aliases: -q
228228directive : option
229229args : <JSON>
230230description : |
231- Provides a :term:`JSON document` as a query that optionally limits
232- the documents returned in the export. Specify JSON in :doc:`strict
231+ Provides a query as a :term:`JSON document` (enclosed in quotes) to
232+ return matching documents in the export. Specify JSON in :doc:`strict
233233 format </reference/mongodb-extended-json>`.
234234
235235 .. include:: /includes/fact-quote-command-line-query.rst
@@ -239,26 +239,29 @@ description: |
239239
240240 .. code:: json
241241
242- { "_id" : ObjectId("51f0188846a64a1ed98fde7c"), "a" : 1 }
243- { "_id" : ObjectId("520e61b0c6646578e3661b59"), "a" : 1, "b" : 2 }
244- { "_id" : ObjectId("520e642bb7fa4ea22d6b1871"), "a" : 2, "b" : 3, "c" : 5 }
245- { "_id" : ObjectId("520e6431b7fa4ea22d6b1872"), "a" : 3, "b" : 3, "c" : 6 }
246- { "_id" : ObjectId("520e6445b7fa4ea22d6b1873"), "a" : 5, "b" : 6, "c" : 8 }
242+ { "_id" : ObjectId("51f0188846a64a1ed98fde7c"), "a" : 1, "date" : ISODate("1960-05-01T00:00:00Z") }
243+ { "_id" : ObjectId("520e61b0c6646578e3661b59"), "a" : 1, "b" : 2, "date" : ISODate("1970-05-01T00:00:00Z") }
244+ { "_id" : ObjectId("520e642bb7fa4ea22d6b1871"), "a" : 2, "b" : 3, "c" : 5, "date" : ISODate("2010-05-01T00:00:00Z") }
245+ { "_id" : ObjectId("520e6431b7fa4ea22d6b1872"), "a" : 3, "b" : 3, "c" : 6, "date" : ISODate("2015-05-02T00:00:00Z") }
246+ { "_id" : ObjectId("520e6445b7fa4ea22d6b1873"), "a" : 5, "b" : 6, "c" : 8, "date" : ISODate("2018-03-01T00:00:00Z") }
247+ { "_id" : ObjectId("5cd0de910dbce4346295ae28"), "a" : 15, "b" : 5, "date" : ISODate("2015-03-01T00:00:00Z") }
247248
248249 The following :binary:`~bin.mongoexport` uses the :option:`-q` option to
249250 export only the documents with the field ``a`` greater than or equal to
250- (:query:`$gte`) to ``3``:
251+ (:query:`$gte`) to ``3`` and the field ``date`` less than
252+ ``ISODate("2016-01-01T00:00:00Z")`` (using the :ref:`strict format
253+ for dates { "$date": "YYYY-MM-DDTHH:mm:ss.mmm\<offset\>"} <extended-json-date>`):
251254
252255 .. code:: bash
253256
254- mongoexport -d test -c records -q '{ a: { $gte: 3 } }' --out exportdir/myRecords.json
257+ mongoexport -d test -c records -q '{ a: { $gte: 3 }, date: { $lt: { "$date": "2016-01-01T00:00:00.000Z" } } }' --out exportdir/myRecords.json
255258
256259 The resulting file contains the following documents:
257260
258261 .. code:: json
259262
260- { "_id" : { "$oid" : "520e6431b7fa4ea22d6b1872" }, "a" : 3, "b" : 3, "c" : 6 }
261- { "_id" : { "$oid" : "520e6445b7fa4ea22d6b1873" }, "a" : 5, "b" : 6, "c" : 8 }
263+ {"_id":{ "$oid": "520e6431b7fa4ea22d6b1872"}, "a":3.0, "b":3.0, "c":6.0,"date":{"$date":"2015-05-02T00:00:00Z"} }
264+ {"_id":{ "$oid":"5cd0de910dbce4346295ae28"}, "a":15.0, "b":5.0,"date":{"$date":"2015-03-01T00:00:00Z"} }
262265
263266 You can sort the results with the :option:`--sort` option to
264267 :binary:`~bin.mongoexport`.
0 commit comments