Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs updates #24

Merged
merged 4 commits into from
Dec 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions notebooks/CRUD-Guide.ipynb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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