From afd8da4e9e8ebf2409df476da5051c4d5348f18a Mon Sep 17 00:00:00 2001 From: Harry Cordewener Date: Thu, 18 Apr 2024 05:12:56 -0400 Subject: [PATCH] Exclusive lock option (#70) * Initial Commit to add the Exclusive Lock to Document operations. * Format Fixes and an editor config so contributors are consistent at least on that point. * More spacing fixes. * Minor version up to be polite. --- .editorconfig | 12 +++++ Core.Arango.sln | 9 +++- Core.Arango/Core.Arango.csproj | 2 +- Core.Arango/Core.Arango.xml | 28 +++++------ Core.Arango/Modules/IArangoDocumentModule.cs | 26 +++++----- .../Modules/Internal/ArangoDocumentModule.cs | 48 ++++++++++++++----- 6 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..c8bf5a56ad --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 \ No newline at end of file diff --git a/Core.Arango.sln b/Core.Arango.sln index d062ad0dd7..a5b9ad6783 100644 --- a/Core.Arango.sln +++ b/Core.Arango.sln @@ -1,12 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.156 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34723.18 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Arango", "Core.Arango\Core.Arango.csproj", "{6B8D05CE-CCB7-4FC4-A85F-EADDEF305999}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Arango.Tests", "Core.Arango.Tests\Core.Arango.Tests.csproj", "{F31E2F80-FFFB-43DA-9C6B-971B854D1E35}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{13D67C1C-3066-4412-A1F6-9C9AD13B7C81}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Core.Arango/Core.Arango.csproj b/Core.Arango/Core.Arango.csproj index 499158290c..65d3977ab3 100644 --- a/Core.Arango/Core.Arango.csproj +++ b/Core.Arango/Core.Arango.csproj @@ -9,7 +9,7 @@ .NET driver for ArangoDB with support for database per tenant deployments Apache-2.0 - 3.0.0 + 3.0.1 Andreas Dominik Jung true ArangoDB.png diff --git a/Core.Arango/Core.Arango.xml b/Core.Arango/Core.Arango.xml index 90bf79307d..aa602c9bfe 100644 --- a/Core.Arango/Core.Arango.xml +++ b/Core.Arango/Core.Arango.xml @@ -2731,32 +2731,32 @@ - + Creates multiple documents - + Creates multiple documents - + Create document - + Create document - + Removes multiple documents - + Removes single document by key @@ -2771,42 +2771,42 @@ Bulk import - + Replaces multiple documents - + Replaces multiple documents - + Replace single document - + Replace single document - + Updates multiple documents - + Updates multiple documents - + Updates single document - + Updates single document diff --git a/Core.Arango/Modules/IArangoDocumentModule.cs b/Core.Arango/Modules/IArangoDocumentModule.cs index 9a9c9640d4..142f2a955d 100644 --- a/Core.Arango/Modules/IArangoDocumentModule.cs +++ b/Core.Arango/Modules/IArangoDocumentModule.cs @@ -63,6 +63,7 @@ Task>> CreateManyAsync(ArangoHandle database, bool? returnOld = null, bool? returnNew = null, bool? silent = null, + bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default); @@ -78,6 +79,7 @@ Task>> CreateManyAsync(ArangoHandle datab bool? returnOld = null, bool? returnNew = null, bool? silent = null, + bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default); @@ -92,6 +94,7 @@ Task> CreateAsync(ArangoHandle database, bool? returnOld = null, bool? returnNew = null, bool? silent = null, + bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default); @@ -106,6 +109,7 @@ Task> CreateAsync(ArangoHandle database, bool? returnOld = null, bool? returnNew = null, bool? silent = null, + bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default); @@ -113,15 +117,15 @@ Task> CreateAsync(ArangoHandle database, /// Removes multiple documents /// Task>> DeleteManyAsync(ArangoHandle database, string collection, - IEnumerable docs, bool? waitForSync = null, bool? returnOld = null, bool? ignoreRevs = null, + IEnumerable docs, bool? waitForSync = null, bool? returnOld = null, bool? ignoreRevs = null, bool? exclusive = null, CancellationToken cancellationToken = default); /// /// Removes single document by key /// Task> DeleteAsync(ArangoHandle database, string collection, string key, - bool? waitForSync = null, bool? returnOld = null, bool? silent = null, string ifMatch = null, - CancellationToken cancellationToken = default); + bool? waitForSync = null, bool? returnOld = null, bool? silent = null, bool? exclusive = null, + string ifMatch = null, CancellationToken cancellationToken = default); /// /// Export all documents in batches from a collection (Query.ExecuteStreamAsync) @@ -141,7 +145,7 @@ Task ImportAsync(ArangoHandle database, string collection, IEnumerable doc /// Task>> ReplaceManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? returnOld = null, bool? returnNew = null, - bool? ignoreRevs = null, + bool? ignoreRevs = null, bool? exclusive = null, CancellationToken cancellationToken = default); /// @@ -149,7 +153,7 @@ Task>> ReplaceManyAsync(ArangoHandle database /// Task>> ReplaceManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? returnOld = null, bool? returnNew = null, - bool? ignoreRevs = null, + bool? ignoreRevs = null, bool? exclusive = null, CancellationToken cancellationToken = default); /// @@ -157,14 +161,14 @@ Task>> ReplaceManyAsync(ArangoHandle data /// Task> ReplaceAsync(ArangoHandle database, string collection, T doc, bool waitForSync = false, bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, - CancellationToken cancellationToken = default); + bool? exclusive = null, CancellationToken cancellationToken = default); /// /// Replace single document /// Task> ReplaceAsync(ArangoHandle database, string collection, T doc, bool waitForSync = false, bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, - CancellationToken cancellationToken = default); + bool? exclusive = null, CancellationToken cancellationToken = default); /// /// Updates multiple documents @@ -172,7 +176,7 @@ Task> ReplaceAsync(ArangoHandle database, stri Task>> UpdateManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, - CancellationToken cancellationToken = default); + bool? exclusive = null, CancellationToken cancellationToken = default); /// /// Updates multiple documents @@ -180,14 +184,14 @@ Task>> UpdateManyAsync(ArangoHandle datab Task>> UpdateManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, - CancellationToken cancellationToken = default); + bool? exclusive = null, CancellationToken cancellationToken = default); /// /// Updates single document /// Task> UpdateAsync(ArangoHandle database, string collection, T doc, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, - bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, bool? exclusive = null, CancellationToken cancellationToken = default); /// @@ -195,7 +199,7 @@ Task> UpdateAsync(ArangoHandle database, strin /// Task> UpdateAsync(ArangoHandle database, string collection, T doc, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, - bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, bool? exclusive = null, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/Core.Arango/Modules/Internal/ArangoDocumentModule.cs b/Core.Arango/Modules/Internal/ArangoDocumentModule.cs index e20e347ba8..c0f4fcde18 100644 --- a/Core.Arango/Modules/Internal/ArangoDocumentModule.cs +++ b/Core.Arango/Modules/Internal/ArangoDocumentModule.cs @@ -51,7 +51,7 @@ public async Task> GetManyAsync(ArangoHandle database, string collect public async Task>> CreateManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, - bool? silent = null, ArangoOverwriteMode? overwriteMode = null, + bool? silent = null, bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default) { var parameter = new Dictionary(); @@ -65,6 +65,9 @@ public async Task>> CreateManyAsync(ArangoHan if (mergeObjects.HasValue) parameter.Add("mergeObjects", mergeObjects.Value.ToString().ToLowerInvariant()); + if (exclusive.HasValue) + parameter.Add("exclusive", mergeObjects.Value.ToString().ToLowerInvariant()); + if (returnOld.HasValue) parameter.Add("returnOld", returnOld.Value.ToString().ToLowerInvariant()); @@ -86,23 +89,23 @@ public async Task>> CreateManyAsync(ArangoHan public async Task>> CreateManyAsync(ArangoHandle database, string collection, IEnumerable docs, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, - bool? silent = null, ArangoOverwriteMode? overwriteMode = null, + bool? silent = null, bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default) { return await CreateManyAsync(database, collection, docs, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, overwriteMode, cancellationToken).ConfigureAwait(false); + returnOld, returnNew, silent, exclusive, overwriteMode, cancellationToken).ConfigureAwait(false); } public async Task> CreateAsync(ArangoHandle database, string collection, T doc, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, - bool? silent = null, ArangoOverwriteMode? overwriteMode = null, + bool? silent = null, bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default) { var res = await CreateManyAsync(database, collection, new List { doc }, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, overwriteMode, cancellationToken).ConfigureAwait(false); + returnOld, returnNew, silent, exclusive, overwriteMode, cancellationToken).ConfigureAwait(false); return res?.SingleOrDefault(); } @@ -111,11 +114,11 @@ public async Task> CreateAsync(ArangoHandle da T doc, bool? waitForSync = null, bool? keepNull = null, bool? mergeObjects = null, bool? returnOld = null, bool? returnNew = null, bool? silent = null, - ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default) + bool? exclusive = null, ArangoOverwriteMode? overwriteMode = null, CancellationToken cancellationToken = default) { var res = await CreateManyAsync(database, collection, new List { doc }, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, overwriteMode, cancellationToken); + returnOld, returnNew, silent, exclusive, overwriteMode, cancellationToken); return res?.SingleOrDefault(); } @@ -142,6 +145,7 @@ public async Task> DeleteAsync(ArangoHandle database, bool? waitForSync = null, bool? returnOld = null, bool? silent = null, + bool? exclusive = null, string ifMatch = null, CancellationToken cancellationToken = default) { @@ -153,6 +157,9 @@ public async Task> DeleteAsync(ArangoHandle database, if (returnOld.HasValue) parameter.Add("returnOld", returnOld.Value.ToString().ToLowerInvariant()); + if (exclusive.HasValue) + parameter.Add("exclusive", exclusive.Value.ToString().ToLowerInvariant()); + if (silent.HasValue) parameter.Add("silent", silent.Value.ToString().ToLowerInvariant()); @@ -174,6 +181,7 @@ public async Task>> DeleteManyAsync(ArangoHan bool? waitForSync = null, bool? returnOld = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var parameter = new Dictionary(); @@ -204,11 +212,12 @@ public async Task>> UpdateManyAsync(Arang bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { return await UpdateManyAsync(database, collection, docs, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, ignoreRevs, cancellationToken).ConfigureAwait(false); + returnOld, returnNew, silent, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); } public async Task>> UpdateManyAsync(ArangoHandle database, @@ -220,6 +229,7 @@ public async Task>> UpdateManyAsync(ArangoHan bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var parameter = new Dictionary(); @@ -245,6 +255,9 @@ public async Task>> UpdateManyAsync(ArangoHan if (ignoreRevs.HasValue) parameter.Add("ignoreRevs", ignoreRevs.Value.ToString().ToLowerInvariant()); + if (exclusive.HasValue) + parameter.Add("exclusive", ignoreRevs.Value.ToString().ToLowerInvariant()); + var query = AddQueryString( ApiPath(database, $"document/{UrlEncode(collection)}"), parameter); @@ -261,11 +274,12 @@ public async Task> UpdateAsync(ArangoHandle da bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var res = await UpdateManyAsync(database, collection, new List { doc }, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, ignoreRevs, cancellationToken).ConfigureAwait(false); + returnOld, returnNew, silent, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); return res.SingleOrDefault(); } @@ -279,11 +293,12 @@ public async Task> UpdateAsync(ArangoHandle databa bool? returnNew = null, bool? silent = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var res = await UpdateManyAsync(database, collection, new List { doc }, waitForSync, keepNull, mergeObjects, - returnOld, returnNew, silent, ignoreRevs, cancellationToken).ConfigureAwait(false); + returnOld, returnNew, silent, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); return res?.SingleOrDefault(); } @@ -294,6 +309,7 @@ public async Task>> ReplaceManyAsync(ArangoHa bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var parameter = new Dictionary(); @@ -307,6 +323,9 @@ public async Task>> ReplaceManyAsync(ArangoHa if (returnNew.HasValue) parameter.Add("returnNew", returnNew.Value.ToString().ToLowerInvariant()); + if (exclusive.HasValue) + parameter.Add("exclusive", returnNew.Value.ToString().ToLowerInvariant()); + if (ignoreRevs.HasValue) parameter.Add("ignoreRevs", ignoreRevs.Value.ToString().ToLowerInvariant()); @@ -323,10 +342,11 @@ public async Task>> ReplaceManyAsync(Aran bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { return await ReplaceManyAsync(database, collection, docs, - waitForSync, returnOld, returnNew, ignoreRevs, cancellationToken).ConfigureAwait(false); + waitForSync, returnOld, returnNew, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); } public async Task> ReplaceAsync(ArangoHandle database, string collection, @@ -335,10 +355,11 @@ public async Task> ReplaceAsync(ArangoHandle datab bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var res = await ReplaceManyAsync(database, collection, new List { doc }, - waitForSync, returnOld, returnNew, ignoreRevs, cancellationToken).ConfigureAwait(false); + waitForSync, returnOld, returnNew, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); return res?.SingleOrDefault(); } @@ -349,10 +370,11 @@ public async Task> ReplaceAsync(ArangoHandle d bool? returnOld = null, bool? returnNew = null, bool? ignoreRevs = null, + bool? exclusive = null, CancellationToken cancellationToken = default) { var res = await ReplaceManyAsync(database, collection, new List { doc }, - waitForSync, returnOld, returnNew, ignoreRevs, cancellationToken).ConfigureAwait(false); + waitForSync, returnOld, returnNew, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false); return res?.SingleOrDefault(); }