Skip to content

Commit 86ae2c0

Browse files
val's comments
1 parent 30e42de commit 86ae2c0

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed
File renamed without changes.

lib/schema.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const setPopulatedVirtualValue = require('./helpers/populate/setPopulatedVirtual
2525
const setupTimestamps = require('./helpers/timestamps/setupTimestamps');
2626
const utils = require('./utils');
2727
const validateRef = require('./helpers/populate/validateRef');
28-
const { inferBSONType } = require('./encryption_utils');
28+
const { inferBSONType } = require('./encryptionUtils');
2929

3030
const hasNumericSubpathRegex = /\.\d+(\.|$)/;
3131

@@ -131,7 +131,6 @@ function Schema(obj, options) {
131131
this.$id = ++id;
132132
this.mapPaths = [];
133133
this.encryptedFields = {};
134-
this._encryptionType = options?.encryptionType;
135134

136135
this.s = {
137136
hooks: new Kareem()
@@ -523,7 +522,7 @@ Schema.prototype.pick = function(paths, options) {
523522
}
524523

525524
if (!this._hasEncryptedFields()) {
526-
newSchema._encryptionType = null;
525+
newSchema.options.encryptionType = null;
527526
}
528527

529528
return newSchema;
@@ -695,9 +694,9 @@ Schema.prototype._defaultToObjectOptions = function(json) {
695694
*/
696695
Schema.prototype.encryptionType = function encryptionType(encryptionType) {
697696
if (typeof encryptionType === 'string' || encryptionType === null) {
698-
this._encryptionType = encryptionType;
697+
this.options.encryptionType = encryptionType;
699698
} else {
700-
return this._encryptionType;
699+
return this.options.encryptionType;
701700
}
702701
};
703702

test/encrypted_schema.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ describe('encrypted schema declaration', function() {
359359
const schema1 = new Schema({ name: { type: String, encrypt: { keyId: KEY_ID, algorithm } } }, { encryptionType: 'csfle' });
360360
const schema2 = schema1.clone();
361361

362-
assert.equal(schema2._encryptionType, 'csfle');
362+
assert.equal(schema2.encryptionType(), 'csfle');
363363
});
364364
describe('When the cloned schema is modified', function() {
365365
it('The original is not modified', function() {

0 commit comments

Comments
 (0)