factbook.json/MONGO.md

64 lines
1.2 KiB
Markdown
Raw Normal View History

2017-03-28 15:37:26 +02:00
# Mongo
## Query Examples
2017-03-28 15:40:40 +02:00
### Find all countries speaking _X_?
2017-03-28 15:37:26 +02:00
German
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "People and Society.Languages.text": /German/ }, { "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
English
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "People and Society.Languages.text": /English/ }, { "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
2017-03-28 15:40:40 +02:00
### Find all countries with a land border with _X_?
2017-03-28 15:37:26 +02:00
Austria
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Austria/ },
2017-03-28 15:39:20 +02:00
{ "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
Germany
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "Geography.Land boundaries.border countries.text": /Germany/ },
2017-03-28 15:39:20 +02:00
{ "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
2017-03-28 15:40:40 +02:00
### Find all import partner countries for _X_?
2017-03-28 15:37:26 +02:00
Austria
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "Economy.Imports - partners.text": /Austria/ }, { "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
### Find all countries with voting age 16 years
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "Government.Suffrage.text": /16/ },
2017-03-28 15:39:20 +02:00
{ "Government.Country name": 1, "Government.Suffrage": 1 })
2017-03-28 15:37:26 +02:00
```
2017-03-28 15:40:40 +02:00
### Find all countries with _X_ membership?
2017-03-28 15:37:26 +02:00
NATO
2017-03-28 15:39:20 +02:00
```js
2017-03-28 15:42:57 +02:00
db.factbook.find( { "Government.International organization participation.text": /NATO/ },
2017-03-28 15:39:20 +02:00
{ "Government.Country name": 1 } )
2017-03-28 15:37:26 +02:00
```
And so on.