diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3ef1073..f520528 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "fantomas": { - "version": "5.1.3", + "version": "6.2.1", "commands": [ "fantomas" ] diff --git a/.gitignore b/.gitignore index 7096b38..f21d1c6 100644 --- a/.gitignore +++ b/.gitignore @@ -442,4 +442,7 @@ $RECYCLE.BIN/ !.vscode/extensions.json *.fs.js -*.mjs \ No newline at end of file +*.mjs + +# Direnv +.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1939523 --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1693611461, + "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695318763, + "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e12483116b3b51a185a33a272bf351e357ba9a99", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1693471703, + "narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..eab72fa --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + outputs = { self, nixpkgs, flake-parts }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + perSystem = { system, pkgs, ... }: { + # Basically "patches" the `pkgs` input to `perSystem` + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "mongodb" "mongodb-compass" ]; + }; + formatter = pkgs.nixfmt; + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; + [ dotnet-sdk ]; + shellHook = '' + dotnet tool restore + ''; + }; + }; + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + }; +} diff --git a/src/Mondocks.Net/Mondocks.Net.fsproj b/src/Mondocks.Net/Mondocks.Net.fsproj index cf1b194..4411a51 100644 --- a/src/Mondocks.Net/Mondocks.Net.fsproj +++ b/src/Mondocks.Net/Mondocks.Net.fsproj @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/src/Mondocks.Net/Types.fs b/src/Mondocks.Net/Types.fs index 6f4b732..b2849aa 100644 --- a/src/Mondocks.Net/Types.fs +++ b/src/Mondocks.Net/Types.fs @@ -1,15 +1,22 @@ namespace Mondocks.Types +open MongoDB.Bson open MongoDB.Bson.Serialization.Attributes [] type Cursor<'T> = { firstBatch: seq<'T>; ns: string } +[] type FindResult<'T> = { cursor: Cursor<'T>; ok: float } [] type InsertResult = { n: int; ok: float } +[] +type UpdateResult = { n: int; nModified: int; ok: float } + +[] +type DeleteResult = { n: int; ok: float } [] type CreateIndexResult = diff --git a/src/Mondocks/Database.fs b/src/Mondocks/Database.fs index 5ac0c5e..3af047d 100644 --- a/src/Mondocks/Database.fs +++ b/src/Mondocks/Database.fs @@ -68,7 +68,7 @@ type IndexBuilder(name: string, serialize: SerializerFn) = wildcardProjection = None } member inline this.Run(state: Index<'PartialFilterExpression, 'StorageEngine, 'Weights, 'WildcardProjection>) = - this.Serialize { state with name = this.Name } + { state with name = this.Name } [] member inline __.Key