From f65826d0d7f6adf3d4cb86fd13139e1810b5c035 Mon Sep 17 00:00:00 2001 From: Gerald Bauer Date: Tue, 28 Mar 2017 15:37:26 +0200 Subject: [PATCH] Create MONGO.md --- MONGO.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 MONGO.md diff --git a/MONGO.md b/MONGO.md new file mode 100644 index 00000000..cde6b14a --- /dev/null +++ b/MONGO.md @@ -0,0 +1,60 @@ + +# Mongo + + +## Query Examples + +### Find all countries speaking ? + +German + +``` +db.factbook.find( { "People and Society.Languages.text": /German/}, { "Government.Country name": 1 } ) +``` + +English + +``` +db.factbook.find( { "People and Society.Languages.text": /English/}, { "Government.Country name": 1 } ) +``` + +### Find all countries with a land border with ? + +Austria + +``` +db.factbook.find( { "Geography.Land boundaries.border countries.text": /Austria/}, { "Government.Country name": 1 } ) +``` + +Germany + +``` +db.factbook.find( { "Geography.Land boundaries.border countries.text": /Germany/}, { "Government.Country name": 1 } ) +``` + + +### Find all import partner countries for ? + +Austria + +``` +db.factbook.find( { "Economy.Imports - partners.text": /Austria/}, { "Government.Country name": 1 } ) +``` + +### Find all countries with voting age 16 years + +``` +db.factbook.find( { "Government.Suffrage.text": /16/}, { "Government.Country name": 1, "Government.Suffrage": 1 }) +``` + + +### Find all countries with membership? + +NATO + +``` +db.factbook.find( { "Government.International organization participation.text": /NATO/}, { "Government.Country name": 1 } ) +``` + +And so on. +