Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 8 additions & 26 deletions java/10_find.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,9 @@
"outputs": [],
"source": [
"Bson booksAfter2008 = gt(\"year\", 2008);\n",
"FindIterable<Document> cursor = books.find(booksAfter2008);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(booksAfter2008)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson())); "
]
},
{
Expand All @@ -202,15 +196,9 @@
"Bson booksWithLessThan50pages = lt(\"pages\", 50);\n",
"Bson showOnlyTitleAndPages = Projections.fields(Projections.include(\"title\", \"pages\"));\n",
"\n",
"FindIterable<Document> cursor = books.find(booksWithLessThan50pages).projection(showOnlyTitleAndPages);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(booksWithLessThan50pages)\n",
" .projection(showOnlyTitleAndPages)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand Down Expand Up @@ -238,15 +226,9 @@
" Projections.excludeId()\n",
");\n",
"\n",
"FindIterable<Document> cursor = books.find(booksWithLessThan50pages).projection(showOnlyTitleAndPagesNoId);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(booksWithLessThan50pages)\n",
" .projection(showOnlyTitleAndPagesNoId)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson())); "
]
},
{
Expand Down
41 changes: 8 additions & 33 deletions java/11_find_arrays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,8 @@
"outputs": [],
"source": [
"Bson poetryBooks = eq(\"genres\", \"Poetry\");\n",
"FindIterable<Document> cursor = books.find(poetryBooks);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(poetryBooks)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand All @@ -123,15 +116,9 @@
"outputs": [],
"source": [
"Bson familyLifeAndFictionBooks = all(\"genres\", \"Family Life\", \"Fiction\");\n",
"FindIterable<Document> cursor = books.find(familyLifeAndFictionBooks);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(familyLifeAndFictionBooks)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand All @@ -154,15 +141,9 @@
"outputs": [],
"source": [
"Bson familyLifeOrFictionBooks = in(\"genres\", \"Family Life\", \"Fiction\");\n",
"FindIterable<Document> cursor = books.find(familyLifeOrFictionBooks);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(familyLifeOrFictionBooks)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand All @@ -187,15 +168,9 @@
"outputs": [],
"source": [
"Bson poetryAndFictionBooks = eq(\"genres\", Arrays.asList(\"Poetry\", \"Fiction\"));\n",
"FindIterable<Document> cursor = books.find(poetryAndFictionBooks);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(poetryAndFictionBooks)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
}
],
Expand Down
22 changes: 4 additions & 18 deletions java/30_insert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,8 @@
"source": [
"Document bookFrom1500 = new Document(\"year\", 1500);\n",
"\n",
"FindIterable<Document> cursor = books.find(bookFrom1500);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(bookFrom1500)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand All @@ -153,15 +146,8 @@
"source": [
"Document bookFrom1500 = new Document(\"_id\", new ObjectId(\"\")); // add the _id here!\n",
"\n",
"FindIterable<Document> cursor = books.find(bookFrom1500);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(bookFrom1500)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson()));"
]
},
{
Expand Down
11 changes: 2 additions & 9 deletions java/40_delete.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,8 @@
"source": [
"Document bookFrom1500 = new Document(\"_id\", \"platero\"); \n",
"\n",
"FindIterable<Document> cursor = books.find(bookFrom1500);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(bookFrom1500)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson())); "
]
},
{
Expand Down
11 changes: 2 additions & 9 deletions java/50_update.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,8 @@
"source": [
"Document elQuijote = new Document(\"_id\", \"quijote\"); \n",
"\n",
"FindIterable<Document> cursor = books.find(elQuijote);\n",
"\n",
"if (cursor != null) {\n",
" for(Document b: cursor) {\n",
" System.out.println(\"Book: \" + b.toJson());\n",
" }\n",
"} else {\n",
" System.out.println(\"Empty collection\");\n",
"}"
"books.find(elQuijote)\n",
" .forEach(b -> System.out.println(\"Book: \" + b.toJson())); "
]
},
{
Expand Down
Loading