Reputation: 76
Do we need a model/schema to just read data from a mongodb database. I have this nodejs application with data already stored in mongodb. But the structure of the documents can change and schema diesnt allow for change. So is it possible to read data without using a schema in mongoose or should I use the nodejs mongodb driver for this. Thanks
Upvotes: 1
Views: 131
Reputation: 24565
Mongoose allows you to access the connection/db object, which will allow you to access your collections. You can then execute queries directly on a specific collection, without having to deal with models/schemas:
let yourCollection = mongoose.connection.db.collection('<tbd>');
const result = await yourCollection.find({...});
Upvotes: 1