Skip to content

Commit

Permalink
Docs updates (#24)
Browse files Browse the repository at this point in the history
* docs remove unused cell

* docs add doc comments

* add docs file

* feature
  relax requirements for update::updates
  relax requirements for delete::deletes
* docs add doc comments
  • Loading branch information
AngelMunoz committed Dec 17, 2020
1 parent e3f7cca commit f01a59e
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 33 deletions.
7 changes: 0 additions & 7 deletions notebooks/CRUD-Guide.ipynb
@@ -1,12 +1,5 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
77 changes: 77 additions & 0 deletions src/Mondocks/Aggregation.fs
Expand Up @@ -8,6 +8,11 @@ module Aggregation =

[<AutoOpen>]
module Count =

/// <summary>
/// Represents a `Count` command
/// for more information take a look at <a href="https://docs.mongodb.com/manual/reference/command/count/#syntax">count syntax</a>
/// </summary>
type CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment> =
{ count: string
query: Option<'TDocument>
Expand Down Expand Up @@ -36,18 +41,61 @@ module Aggregation =

member __.Run(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>) = (state :> IBuilder).ToJSON()

///<summary>The name of the collection to query against</summary>
/// <example>
/// count {
/// collection "users"
/// query {| age = 50 |}
/// }
/// </example>
[<CustomOperation("collection")>]
member __.Count(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>, count: string) =
{ state with count = count }

/// <summary>
/// Optional object that is going to be used to filter the find query
/// </summary>
/// <example>
/// count {
/// collection "users"
/// // counts all the users with the name "Frank"
/// query {| name = "Frank"|}
/// }
/// </example>
[<CustomOperation("query")>]
member __.Query(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>, query: 'TDocument) =
{ state with query = Some query }

/// <summary>
/// Optional. An integer value used to omit the first n amount of documents from the find query
/// Use together with Limit to paginate results
/// </summary>
/// <example>
/// count {
/// collection "users"
/// // ... omit other fields
/// // omits the first 10 results of the count query
/// skip 10
/// // ... omit other fields
/// }
/// </example>
[<CustomOperation("limit")>]
member __.Limit(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>, limit: int) =
{ state with limit = Some limit }

/// <summary>
/// Optional. An integer value used to take at most n amount of documents
/// Use together with Skip to paginate results
/// </summary>
/// <example>
/// count {
/// collection "users"
/// // ... omit other fields
/// // takes only 10 documents from the count query
/// limit 10
/// // ... omit other fields
/// }
/// </example>
[<CustomOperation("skip")>]
member __.Skip(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>, skip: int) =
{ state with skip = Some skip }
Expand All @@ -65,11 +113,19 @@ module Aggregation =
member __.Comment(state: CountCommand<'TDocument, 'Hint, 'ReadConcern, 'Comment>, comment: 'Comment) =
{ state with comment = Some comment }

/// <summary>Creates an count command for documents in the specified collection</summary>
/// <param name="collection">The name of the collection to perform this query against</param>
/// <returns>returns a <see cref="Mondocks.Aggregation.Count.CountCommandBuilder">CountCommandBuilder</see></returns>
let count = CountCommandBuilder()


[<AutoOpen>]
module Distinct =

/// <summary>
/// Represents a `Distinct` command
/// for more information take a look at <a href="https://docs.mongodb.com/manual/reference/command/distinct/#syntax">count syntax</a>
/// </summary>
type DistinctCommand<'TDocument, 'ReadConcern, 'Comment> =
{ distinct: string
key: string
Expand All @@ -95,10 +151,28 @@ module Aggregation =
({ state with distinct = collection } :> IBuilder)
.ToJSON()

/// <summary>
/// A key used to retreive values from the query result documents
/// </summary>
/// <example>
/// distinct "users" {
/// key "email"
/// }
/// </example>
[<CustomOperation("key")>]
member __.Key(state: DistinctCommand<'TDocument, 'ReadConcern, 'Comment>, key: string) =
{ state with key = key }

/// <summary>
/// Optional. A filter to query against the collection
/// </summary>
/// <example>
/// distinct "users" {
/// // gets all of the distinc emails from users named "Frank"
/// key "email"
/// query {| name = "Frank"|}
/// }
/// </example>
[<CustomOperation("query")>]
member __.Query(state: DistinctCommand<'TDocument, 'ReadConcern, 'Comment>, query: 'TDocument) =
{ state with query = Some query }
Expand All @@ -117,4 +191,7 @@ module Aggregation =
member __.Comment(state: DistinctCommand<'TDocument, 'ReadConcern, 'Comment>, comment: 'Comment) =
{ state with comment = Some comment }

/// <summary>Creates an update command for documents in the specified collection</summary>
/// <param name="collection">The name of the collection to perform this query against</param>
/// <returns>returns a <see cref="Mondocks.Aggregation.Distinct.DistinctCommandBuilder">DistinctCommandBuilder</see></returns>
let distinct (collection: string) = DistinctCommandBuilder(collection)
1 change: 1 addition & 0 deletions src/Mondocks/Mondocks.fsproj
Expand Up @@ -5,6 +5,7 @@
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit f01a59e

Please sign in to comment.