I've gone through MongoDB docs that explain how to configure encryption which is available in MongoDB Enterprise only.
How to implement data at rest in MongoDB Community Edition v3.4?
I've gone through MongoDB docs that explain how to configure encryption which is available in MongoDB Enterprise only.
How to implement data at rest in MongoDB Community Edition v3.4?
Like Alex Blex suggested, you have other options than Community Edition.
However, if you still want to go with Community Edition,
You can use mongoose.js for interacting with mongoDB. It has getters and setters that can fulfill your requirement:
http://mongoosejs.com/docs/2.7.x/docs/getters-setters.html
In your mongoose schema, you can specify
get
andset
functions for fields.The
set
will be executed whenever you are assigning any value to the field. It will take the value as a parameter, and then you can write your own encryption logic.The
get
will be executed whenever you access the field's value. It will get the encrypted value as a parameter and you can write your decryption logic there.You will have to write the
decryptFunction
andencryptFunction
.However, you wont be able to query those fields with original values. As the mongodb does not know the text is encrypted.
I was asking the same question to myself just few month ago. This is a list of options I have found so far: