I'm trying manipulate a JSON that wasn't created by me, only uploaded to mongo. In NodeJs I'm trying:
app.get('/municipios', async (req, res) => {
let cidadeSchema = new Schema({}, { strict: false })
let cidades = mongoose.model('municipios', cidadeSchema)
let cidade = cidades.findOne({name: 'Rio Grande'})
// console.log(cidade)
res.send(CircularJSON.stringify(cidade))
})
but when the JSON is sent, it send only the structure of request to mongo, and if I try once, I receive a message: (node:24536) UnhandledPromiseRejectionWarning: OverwriteModelError: Cannot overwrite municipios
model once compiled.