Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
Cómo obtener valores descifrados en el resultado de la agregación mediante el uso de getter y setter en node.js
var mongoose = require("mongoose"); const Schema = mongoose.Schema; let CryptoJS = require("crypto-js"); function encrypt(text) { try { let ciphertext = CryptoJS.AES.encrypt( text, process.env.MONGOOSE_PII_KEY ).toString(); console.log("encryptencrypt", encrypt); return ciphertext; } catch (err) { console.log("error", err); } } function decrypt(text) { try { let bytes = CryptoJS.AES.decrypt(text, process.env.MONGOOSE_PII_KEY); var originalText = bytes.toString(CryptoJS.enc.Utf8); return originalText; } catch (err) { console.log("error", err); } } var callSchema = new mongoose.Schema( { from: { type: String, default: null, set: encrypt, get: decrypt }, to: { type: String, default: null, set: encrypt, get: decrypt }, }, { versionKey: false, toObject: { getters: true, setters: true }, toJSON: { getters: true, setters: true }, runSettersOnQuery: true, } ); module.exports = mongoose.model("Call", callSchema);

Estoy usando técnicas de encriptación (getters y setter). En la consulta normal de mongo (como find({from: "+91232323233"})) funciona bien, pero cuando trato de obtener el valor "from" del número de teléfono, obtengo un valor cifrado.

¿Es esa alguna solución para obtener valor descifrado mediante el uso de la agregación mongo?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!