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

Add _oldRev property in PatchDocumentsResponse. #270

Merged
merged 2 commits into from
Aug 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ public async Task PatchDocumentsAsync_ShouldSucceed()
Assert.NotEqual(postResponse[0]._rev, response[0]._rev);
Assert.NotEqual(postResponse[0].New.Name, response[0].New.Name);
Assert.Equal(postResponse[0].New.Name, response[0].Old.Name);
Assert.Equal(postResponse[0]._rev, response[0]._oldRev);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions arangodb-net-standard/DocumentApi/DocumentApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public virtual async Task<DeleteDocumentsResponse<T>> DeleteDocumentsAsync<T>(
/// <param name="patches"></param>
/// <param name="query"></param>
/// <returns></returns>
public virtual async Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<T, U>(
public virtual async Task<PatchDocumentsResponse<U>> PatchDocumentsAsync<T, U>(
string collectionName,
IList<T> patches,
PatchDocumentsQuery query = null)
Expand All @@ -446,7 +446,7 @@ public virtual async Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync();
return DeserializeJsonFromStream<IList<PatchDocumentsResponse<U>>>(stream);
return DeserializeJsonFromStream<PatchDocumentsResponse<U>>(stream);
}
throw await GetApiErrorException(response);
}
Expand Down
2 changes: 1 addition & 1 deletion arangodb-net-standard/DocumentApi/IDocumentApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Task<DeleteDocumentsResponse<T>> DeleteDocumentsAsync<T>(
/// <param name="patches"></param>
/// <param name="query"></param>
/// <returns></returns>
Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<T, U>(
Task<PatchDocumentsResponse<U>> PatchDocumentsAsync<T, U>(
string collectionName,
IList<T> patches,
PatchDocumentsQuery query = null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Represents the response for deleting multiple documents.
/// </summary>
/// <typeparam name="T">The type of the deserialized old document object when requested.</typeparam>
public class DeleteDocumentsResponse<T> : List<DeleteDocumentsDocumentResponse<T>>
{
/// <summary>
/// Creates an instance of <see cref="DeleteDocumentsResponse{T}"/>.
/// </summary>
public DeleteDocumentsResponse()
{
}
Expand All @@ -13,6 +20,11 @@ private DeleteDocumentsResponse(int capacity)
{
}

/// <summary>
/// Creates an empty response.
/// This is used when <see cref="DeleteDocumentsQuery.Silent"/> is true.
/// </summary>
/// <returns></returns>
public static DeleteDocumentsResponse<T> Empty()
{
return new DeleteDocumentsResponse<T>(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Represents the response for one document when updating multiple document.
/// </summary>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentsDocumentResponse<T> : PatchDocumentResponse<T>
{
/// <summary>
/// Indicates whether an error occurred.
/// </summary>
public bool Error { get; set; }

/// <summary>
/// Error message.
/// </summary>
public string ErrorMessage { get; set; }

/// <summary>
/// ArangoDB error number.
/// </summary>
public int ErrorNum { get; set; }
}
}
35 changes: 25 additions & 10 deletions arangodb-net-standard/DocumentApi/Models/PatchDocumentsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
namespace ArangoDBNetStandard.DocumentApi.Models
using System.Collections.Generic;

namespace ArangoDBNetStandard.DocumentApi.Models
{
public class PatchDocumentsResponse<U> : DocumentBase
/// <summary>
/// Represents the response for updating multiple documents.
/// </summary>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentsResponse<T> : List<PatchDocumentsDocumentResponse<T>>
{
public U New { get; set; }

public U Old { get; set; }
/// <summary>
/// Creates an instance of <see cref="PatchDocumentsResponse{T}"/>.
/// </summary>
public PatchDocumentsResponse()
{
}

public bool Error { get; set; }
private PatchDocumentsResponse(int capacity)
: base(capacity)
{
}

/// <summary>
/// Error message.
/// Creates an empty response.
/// This is used when <see cref="PostDocumentsQuery.Silent"/> is true.
/// </summary>
public string ErrorMessage { get; set; }

public int ErrorNum { get; set; }
/// <returns></returns>
public static PatchDocumentsResponse<T> Empty()
{
return new PatchDocumentsResponse<T>(0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class PostDocumentsQuery
public bool? ReturnOld { get; set; }

/// <summary>
/// TODO
/// If set to true, an empty object will be returned as response.
/// No meta-data will be returned for the created document.
/// This option can be used to save some network traffic.
/// </summary>
public bool? Silent { get; set; }

Expand Down
12 changes: 10 additions & 2 deletions arangodb-net-standard/DocumentApi/Models/PostDocumentsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Response after posting multiple documents
/// Represents the response for creating multiple documents.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PostDocumentsResponse<T> : List<PostDocumentsDocumentResponse<T>>
{
/// <summary>
/// Creates an instance of <see cref="PostDocumentsResponse{T}"/>.
/// </summary>
public PostDocumentsResponse()
{
}
Expand All @@ -17,6 +20,11 @@ private PostDocumentsResponse(int capacity)
{
}

/// <summary>
/// Creates an empty response.
/// This is used when <see cref="PostDocumentsQuery.Silent"/> is true.
/// </summary>
/// <returns></returns>
public static PostDocumentsResponse<T> Empty()
{
return new PostDocumentsResponse<T>(0);
Expand Down