Skip to content

Commit 9fca6da

Browse files
committed
Fix merge review: eliminate magic strings, update docs for elastic-client
- Replace magic strings "dateCreatedUtc"/"dateUpdatedUtc" in EmployeeWithDateMetaDataIndex with nameof + JsonNamingPolicy.CamelCase - Fix patch-operations.md reference to JToken (Newtonsoft) → JsonNode
1 parent 4c193ec commit 9fca6da

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

.commit-msg.tmp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix merge review: eliminate magic strings, update docs for elastic-client
2+
3+
- Replace magic strings "dateCreatedUtc"/"dateUpdatedUtc" in
4+
EmployeeWithDateMetaDataIndex with nameof + JsonNamingPolicy.CamelCase
5+
- Fix patch-operations.md reference to JToken (Newtonsoft) → JsonNode

docs/guide/patch-operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class MyRepository : ElasticRepositoryBase<MyEntity>
7070
| `GetUpdatedUtcFieldPath()` | Returns the Elasticsearch field path for the updated timestamp | Returns the inferred `UpdatedUtc` field name. Throws `RepositoryException` if `HasDateTracking` is `true` but no field path is available |
7171
| `SetDocumentDates(T, TimeProvider)` | Sets date properties on the C# object (used by Add, Save, ActionPatch, JsonPatch bulk) | Sets `CreatedUtc` and `UpdatedUtc` on `IHaveDates` models |
7272

73-
The `ApplyDateTracking` overloads for `ScriptPatch`, `PartialPatch`, and `JToken` are also virtual and can be overridden for full control over how dates are injected into each patch type. For nested fields, the script parameter key uses the last segment of the field path (e.g., `dateUpdatedUtc` for `metaData.dateUpdatedUtc`).
73+
The `ApplyDateTracking` overloads for `ScriptPatch`, `PartialPatch`, and `JsonNode` are also virtual and can be overridden for full control over how dates are injected into each patch type. For nested fields, the script parameter key uses the last segment of the field path (e.g., `dateUpdatedUtc` for `metaData.dateUpdatedUtc`).
7474

7575
## Patch Types
7676

tests/Foundatio.Repositories.Elasticsearch.Tests/Repositories/Configuration/Indexes/EmployeeWithDateMetaDataIndex.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Text.Json;
12
using Elastic.Clients.Elasticsearch.Mapping;
23
using Foundatio.Repositories.Elasticsearch.Configuration;
34
using Foundatio.Repositories.Elasticsearch.Extensions;
@@ -7,6 +8,8 @@ namespace Foundatio.Repositories.Elasticsearch.Tests.Repositories.Configuration.
78

89
public sealed class EmployeeWithDateMetaDataIndex : Index<EmployeeWithDateMetaData>
910
{
11+
private static string CamelCase(string name) => JsonNamingPolicy.CamelCase.ConvertName(name);
12+
1013
public EmployeeWithDateMetaDataIndex(IElasticConfiguration configuration) : base(configuration, "employees-metadata") { }
1114

1215
public override void ConfigureIndex(Elastic.Clients.Elasticsearch.IndexManagement.CreateIndexRequestDescriptor idx)
@@ -26,8 +29,8 @@ public override void ConfigureIndexMapping(TypeMappingDescriptor<EmployeeWithDat
2629
.Keyword(e => e.CompanyId)
2730
.Object(e => e.MetaData, mp => mp
2831
.Properties(p2 => p2
29-
.Date("dateCreatedUtc")
30-
.Date("dateUpdatedUtc")
32+
.Date(CamelCase(nameof(DateMetaData.DateCreatedUtc)))
33+
.Date(CamelCase(nameof(DateMetaData.DateUpdatedUtc)))
3134
))
3235
);
3336
}

0 commit comments

Comments
 (0)