1 / 1
Sep 2024

Hello Gurus…

Need help with the error mentioned in the subject line.

I have this class

public class Patient : Document { [BsonId] public Guid Id { get; set; } [JsonIgnore] [BsonElement("keyId")] public string? KeyId { get; set; } = "demo-data-key"; public string Name { get; set; } = null!; public int SSN { get; set; } //This is the encrypted field public string? EncryptedPropertyDetails { get; set; } }

Which uses the following SchemaMap:

BsonDocument schema = new BsonDocument { { "bsonType", "object" }, { "encryptMetadata", new BsonDocument{ { "keyId", "/keyId"} } }, { "properties", new BsonDocument { { "EncryptedPropertyDetails", new BsonDocument { { "encrypt", new BsonDocument { { "bsonType", "string" }, { "algorithm", "AEAD_AES_256_CBC_HMAC_SHA_512-Random"} } } } } } } };

Now, with the above, I am able to insert new records and fetch the records properly.

However, whenever I am trying to update the record, getting the above mentioned error.

This is how I am trying to update it:

public async Task UpdatePatientAsync(Guid patiendGuid, Patient patient) { UpdateDefinition<Patient> update = Builders<Patient>.Update .Set(x => x.EncryptedPropertyDetails, patient.EncryptedPropertyDetails) .Set(x => x.Name, patient.Name) .Set(x => x.ModifiedAtUtc, DateTime.UtcNow); FilterDefinition<Patient> filter = Builders<Patient> .Filter .In(x => x.Id, new List<Guid> { patiendGuid }); await _patientRepository.UpdatePatientAsync(filter, update); }

Which works fine if I give a static Key Id…

Is there a way to make it work using JSON Pointer?

Thanks in advance!!

Regards,

UB