mirror of
https://github.com/factbook/factbook.json.git
synced 2026-07-04 19:52:10 +02:00
Update MONGO.md
This commit is contained in:
parent
15c1be98ac
commit
c40c3e00ea
1 changed files with 60 additions and 63 deletions
123
MONGO.md
123
MONGO.md
|
|
@ -1,8 +1,66 @@
|
||||||
|
|
||||||
# Mongo
|
# Mongo
|
||||||
|
|
||||||
[Import](#import) •
|
[Query Examples](#query-examples) •
|
||||||
[Query Examples](#query-examples)
|
[Import](#import)
|
||||||
|
|
||||||
|
|
||||||
|
## Query Examples
|
||||||
|
|
||||||
|
### Find all countries speaking _X_?
|
||||||
|
|
||||||
|
German
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "People and Society.Languages.text": /German/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
English
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "People and Society.Languages.text": /English/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
### Find all countries with a land border with _X_?
|
||||||
|
|
||||||
|
Austria
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Austria/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
Germany
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Germany/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Find all import partner countries for _X_?
|
||||||
|
|
||||||
|
Austria
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "Economy.Imports - partners.text": /Austria/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
### Find all countries with voting age 16 years
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "Government.Suffrage.text": /16/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Find all countries with _X_ membership?
|
||||||
|
|
||||||
|
NATO
|
||||||
|
|
||||||
|
```js
|
||||||
|
db.factbook.find( { "Government.International organization participation.text": /NATO/ } )
|
||||||
|
```
|
||||||
|
|
||||||
|
And so on.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Import
|
## Import
|
||||||
|
|
@ -57,64 +115,3 @@ To check up if all country profiles got imported use a query in the mongo shell
|
||||||
> db.factbook.count()
|
> db.factbook.count()
|
||||||
261
|
261
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Query Examples
|
|
||||||
|
|
||||||
### Find all countries speaking _X_?
|
|
||||||
|
|
||||||
German
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "People and Society.Languages.text": /German/ }, { "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
English
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "People and Society.Languages.text": /English/ }, { "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
### Find all countries with a land border with _X_?
|
|
||||||
|
|
||||||
Austria
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Austria/ },
|
|
||||||
{ "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
Germany
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Germany/ },
|
|
||||||
{ "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Find all import partner countries for _X_?
|
|
||||||
|
|
||||||
Austria
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "Economy.Imports - partners.text": /Austria/ }, { "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
### Find all countries with voting age 16 years
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "Government.Suffrage.text": /16/ },
|
|
||||||
{ "Government.Country name": 1, "Government.Suffrage": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Find all countries with _X_ membership?
|
|
||||||
|
|
||||||
NATO
|
|
||||||
|
|
||||||
```js
|
|
||||||
db.factbook.find( { "Government.International organization participation.text": /NATO/ },
|
|
||||||
{ "Government.Country name": 1 } )
|
|
||||||
```
|
|
||||||
|
|
||||||
And so on.
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue