/ / / / / / /
암호화된 필드가 있는 문서 쿼리
동일성 쿼리를 사용한 Queryable Encryption이 MongoDB 7 에서 GA(일반 사용 가능)로 제공됩니다.0 이상. Queryable Encryption Public Preview, 버전 6 에서 릴리스되었습니다.0, 더 이상 지원되지 않습니다. 공개 미리 보기를 사용하여 암호화된 데이터는 기능 릴리스와 호환되지 않습니다. 자세한 내용은 MongoDB 7 의 호환성 변경 사항을 참조하세요.0.
개요
이 가이드에서는 Queryable Encryption 지원 애플리케이션을 사용하여 암호화된 필드가 있는 문서를 검색하는 방법을 설명합니다.
이 가이드의 단계를 완료하면 애플리케이션을 사용하여 암호화된 필드의 데이터를 쿼리하고 인증된 사용자로 해당 필드를 해독할 수 있습니다.
시작하기 전
계속하기 전에 암호화된 컬렉션을 만들고 문서를 삽입 하세요.
절차
1
암호화된 필드 쿼리
다음 코드 샘플은 암호화된 필드에서 찾기 쿼리를 실행하고 암호가 해독된 데이터를 출력합니다.
const findResult = await encryptedCollection.findOne({ "patientRecord.ssn": "987-65-4320", }); console.log(findResult);
var ssnFilter = Builders<Patient>.Filter.Eq("patientRecord.ssn", patient.PatientRecord.Ssn); var findResult = await encryptedCollection.Find(ssnFilter).ToCursorAsync(); Console.WriteLine(findResult.FirstOrDefault().ToJson());
var findResult PatientDocument err = coll.FindOne( context.TODO(), bson.M{"patientRecord.ssn": "987-65-4320"}, ).Decode(&findResult)
Patient findResult = collection.find( new BsonDocument() .append("patientRecord.ssn", new BsonString("987-65-4320"))) .first(); System.out.println(findResult);
const findResult = await encryptedCollection.findOne({ "patientRecord.ssn": "987-65-4320", }); console.log(findResult);
find_result = encrypted_collection.find_one({ "patientRecord.ssn": "987-65-4320" }) print(find_result)
이전 코드 샘플의 출력은 다음과 유사해야 합니다.
{ "_id": { "$oid": "648b384a722cb9b8392df76a" }, "name": "Jon Doe", "record": { "ssn": "987-65-4320", "billing": { "type": "Visa", "number": "4111111111111111" } }, "__safeContent__": [ { "$binary": { "base64": "L1NsYItk0Sg+oL66DBj6IYHbX7tveANQyrU2cvMzD9Y=", "subType": "00" } } ] }
경고
__safeContent__ 필드를 수정하지 마세요.
__safeContent__
필드는 Queryable Encryption에 필수적입니다. 이 필드의 내용은 수정하지 마세요.