Skip to content

Commit

Permalink
docs fix some grammar mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelMunoz committed Dec 17, 2020
1 parent e3f7cca commit b595865
Showing 1 changed file with 95 additions and 27 deletions.
122 changes: 95 additions & 27 deletions notebooks/CRUD-Guide.ipynb
@@ -1,19 +1,12 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Getting Started\n",
"\n",
"Mondocks is a simple library with one purpose, create MongoDB Json Commands these commands can be executed by the various mongodb drivers that exist out there or even by the mongo shell.\n",
"Mondocks is a simple library with one purpose, create MongoDB Json Commands. these commands can be executed by the various mongodb drivers that exist out there or even by the mongo shell.\n",
"\n",
"You can get started by typing on your console `dotnet add package Mondocks` and you'll be able to open the namespaces and modules that are included in this library\n",
"\n",
Expand All @@ -28,8 +21,8 @@
" \"query contents\"\n",
"}\n",
"```\n",
"So most of the commands will look the same, they will just have different options depending on what do you need to do with them.\n",
"the *builder*'s signatures look a bit crazy and full of generics that might be confusing, in reallity we add the generics so you can use any kind of type you neeed to use, if you want to do query filters by Records because you have a shared filters project, you can query by anonymous records as if you were using a *javascript* object as well it's your choice we try to stay as away as posible to let you decide how do you want to handle your data types\n",
"Most of the commands will look the same, they will just have different options depending on what do you need to do with them.\n",
"The *builder*'s signatures look a bit crazy and full of generics that might be confusing, in reallity we add the generics so you can use any kind of type you neeed to use, if you want to do query filters by Records because you have a shared filters project, you can query by anonymous records as if you were using a *javascript* object as well it's your choice we try to stay as away as posible to let you decide how do you want to handle your data types.\n",
"\n",
"Let's start with some CRUD examples"
]
Expand All @@ -40,7 +33,7 @@
"source": [
"# Insert (Create)\n",
"\n",
"Inserts are fairly straight forward you just need to suply a sequence of objects they can be either records or anonymous records, if you want to go a little bit more dynamix you can also pass boxed objects that have different properties.\n",
"Inserts are fairly straight forward you just need to suply a sequence of objects they can be either records or anonymous records, if you want to go a little bit more dynamic you can also pass boxed objects that have different properties.\n",
"\n",
""
]
Expand Down Expand Up @@ -73,14 +66,6 @@
""
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "Installed package Mondocks version 0.2.0"
},
"execution_count": 1,
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
Expand Down Expand Up @@ -194,7 +179,7 @@
{
"output_type": "execute_result",
"data": {
"text/plain": "{\"insert\":\"posts\",\"documents\":[{\"author\":\"Angel D. Munoz\",\"content\":\"This is the content\",\"title\":\"This is my first post\"},{\"author\":\"Mike Thompson\",\"content\":\"This is the content\",\"createdAt\":{\"$date\":{\"$numberLong\":\"1608146332584\"}},\"title\":\"This is my second post\"},{\"author\":\"Frank Miller\",\"content\":\"This is the content\",\"tags\":[\"mongodb\",\"fsharp\",\"nosql\"],\"title\":\"This is my third post\"}]}"
"text/plain": "{\"insert\":\"posts\",\"documents\":[{\"author\":\"Angel D. Munoz\",\"content\":\"This is the content\",\"title\":\"This is my first post\"},{\"author\":\"Mike Thompson\",\"content\":\"This is the content\",\"createdAt\":{\"$date\":{\"$numberLong\":\"1608230189553\"}},\"title\":\"This is my second post\"},{\"author\":\"Frank Miller\",\"content\":\"This is the content\",\"tags\":[\"mongodb\",\"fsharp\",\"nosql\"],\"title\":\"This is my third post\"}]}"
},
"execution_count": 1,
"metadata": {}
Expand Down Expand Up @@ -225,9 +210,8 @@
"source": [
"# Find (Read)\n",
"\n",
"Read operations can be really simple or they can be complex as well as with the insert queries, most of the time you should only need a couple of properties like `filter`, `limit`, `skip` and maybe `collation`.\n",
"\n",
"Also remember that these filters must be done in the way you'd do them with mongo so you have to use `$in` `$or` and all of those operators, you can find that reference in the mongodb documentation about [Operators](https://docs.mongodb.com/manual/reference/operator/query/)\n",
"Read operations can be really simple or they can be complex like the insert queries, most of the time you should only need a couple of properties like `filter`, `limit`, `skip` and maybe `collation`.\n",
"Also, remember that these filters must be written in the same way you would write them for mongo so you have to use `$in` `$or` and all of those operators, you can find that reference in the mongodb documentation about [Operators](https://docs.mongodb.com/manual/reference/operator/query/)\n",
"\n",
"Let's get onto it."
]
Expand Down Expand Up @@ -524,7 +508,7 @@
"source": [
"# Update\n",
"\n",
"Update operations are fairly straight forward as well although, for the update queries there's a helper type that can be used named `UpdateQuery<'Query, 'Update, 'Hint>`\n",
"Update operations are fairly straight forward as well although, for the update queries there's a helper type that can be used named `UpdateQuery<'Query, 'Update, 'Hint>` which contains all of the availabe properties for the `update` document\n",
"\n",
"let's dive into it"
]
Expand Down Expand Up @@ -585,7 +569,7 @@
{
"output_type": "execute_result",
"data": {
"text/plain": "{\"update\":\"users\",\"updates\":[{\"q\":{\"_id\":{\"$oid\":\"5fda69f944739a88f3dadd84\"}},\"u\":{\"_id\":{\"$oid\":\"5fda69f944739a88f3dadd84\"},\"name\":\"Daniel\",\"age\":{\"$numberInt\":\"28\"},\"email\":\"new@email.com\"}}]}"
"text/plain": "{\"update\":\"users\",\"updates\":[{\"q\":{\"_id\":{\"$oid\":\"5fdba52d6e3b4e6f666b1cc3\"}},\"u\":{\"_id\":{\"$oid\":\"5fdba52d6e3b4e6f666b1cc3\"},\"name\":\"Daniel\",\"age\":{\"$numberInt\":\"28\"},\"email\":\"new@email.com\"}}]}"
},
"execution_count": 1,
"metadata": {}
Expand Down Expand Up @@ -616,6 +600,47 @@
}
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"#!fsharp\n",
"(* In version 0.3.15 of Mondocks we decided to relax a little bit the updates\n",
" you can pass a boxed sequence of anonymous records with only the properties you want \n",
" this allows you to skip other properties that are present inside the \n",
" `UpdateQuery` record\n",
"*)\n",
"\n",
"let upgradeUsersSchema =\n",
" update \"users\" {\n",
" updates [\n",
" box {| q = {||}\n",
" u = {| ``$set`` = {| withNewProperty = true |} |}\n",
" multi = true |}\n",
" ]\n",
" }\n",
"printfn $\"{upgradeUsersSchema}\""
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "{\"update\":\"users\",\"updates\":[{\"multi\":true,\"q\":{},\"u\":{\"$set\":{\"withNewProperty\":true}}}]}"
},
"execution_count": 1,
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": "\r\n"
},
"execution_count": 1,
"metadata": {}
}
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -632,7 +657,7 @@
"source": [
"# Delete\n",
"\n",
"Deletes are very much like Updates there's also a helper type named `DeleteQuery<'Delete, 'Hint, 'Comment>`\n",
"Deletes are very much like Updates there's also a helper type named `DeleteQuery<'Delete, 'Hint, 'Comment>` which contains all of the available properties for the `delete` document\n",
"\n",
"Let's check some samples"
]
Expand All @@ -645,6 +670,7 @@
"#!fsharp\n",
"#r \"nuget: Mondocks\"\n",
"\n",
"open System\n",
"open Mondocks.Queries\n",
"\n",
"let deleteUserWhereName (name: string) =\n",
Expand Down Expand Up @@ -708,7 +734,49 @@
{
"output_type": "execute_result",
"data": {
"text/plain": "{\"delete\":\"users\",\"deletes\":[{\"q\":{\"name\":\"Angel\"},\"limit\":{\"$numberInt\":\"0\"}},{\"q\":{\"lastLogin\":{\"$lte\":{\"$date\":{\"$numberLong\":\"1292790752079\"}}}},\"limit\":{\"$numberInt\":\"0\"}}]}"
"text/plain": "{\"delete\":\"users\",\"deletes\":[{\"q\":{\"name\":\"Angel\"},\"limit\":{\"$numberInt\":\"0\"}},{\"q\":{\"lastLogin\":{\"$lte\":{\"$date\":{\"$numberLong\":\"1292870189947\"}}}},\"limit\":{\"$numberInt\":\"0\"}}]}"
},
"execution_count": 1,
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": "\r\n"
},
"execution_count": 1,
"metadata": {}
}
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"#!fsharp\n",
"(* In version 0.3.15 of Mondocks we decided to relax a little bit the deletes\n",
" you can pass a boxed sequence of anonymous records with only the properties you want \n",
" this allows you to skip other properties that are present inside the \n",
" `DeleteQuery` record\n",
"*)\n",
"\n",
"let relaxedDeletes = \n",
" delete \"users\" {\n",
" deletes [\n",
" // deletes all of the users named Angel\n",
" box {| q = {| name = \"Angel\" |}; limt = 0 |}\n",
" box {| q = {| name = \"Peter\" |}; limt = 4 |}\n",
" box {| q = {| name = \"Frank\" |}; limt = 1 |}\n",
" ]\n",
" }\n",
"printfn $\"%s{relaxedDeletes}\""
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "{\"delete\":\"users\",\"deletes\":[{\"limt\":{\"$numberInt\":\"0\"},\"q\":{\"name\":\"Angel\"}},{\"limt\":{\"$numberInt\":\"4\"},\"q\":{\"name\":\"Peter\"}},{\"limt\":{\"$numberInt\":\"1\"},\"q\":{\"name\":\"Frank\"}}]}"
},
"execution_count": 1,
"metadata": {}
Expand Down

0 comments on commit b595865

Please sign in to comment.