Searching and filtering JSON documents
To do this, we use the worldcol
collection, which is a collection of JSON documents generated from the tables in the world
database. Unless otherwise specified, we will use MySQL Shell in JavaScript mode.
To create this collection, we need to first run the statements in the worldcol.js
file by writing the following query:
\connect —mx [email protected]:33060 \source worldcol.js
This outputs the following results:
To explore, you first need to get a single document from the collection:
db.worldcol.find().limit(1)
This returns the first document of the worldcol
collection:
The find
function accepts an argument to filter rows:
db.worldcol.find('name="Paris"')
This returns the following results: