forgot to say as well, as far as “I’m partial to attempting the native Mongo driver. But if you’re familiar with Mongoose, that makes sense to try first” is concerned, I get you now, you don’t want a api > mongoose > mongo
setup if you can just have a api > mongo
flow.
I thought Mongoose was the preferred one since it was Option 1 on first reading your comment haha.
I’m completely willing to try native MongoDB first and see if it has any pitfalls. As far as Indexing, you cant type it via the field like you can in Mongoose via:
const User = new Schema({
name: { type: String, index: true }
})
and instead has to be done on the collection level:
const createAscendingIndex = function(db, callback) {
// Get the users collection
const collection = db.collection('users');
// Create the index
collection.createIndex(
{ name : 1 }, function(err, result) {
console.log(result);
callback(result);
});
};
so it would need to be something that ran after the model/collection that looks for the indexing happening in the api, and if it does, then stick that function at the end of the model
or
make a big function of all indexes needed schema-wide added at the end.
but due to separation of concerns, im more partial to adding it per model/collection, but obviously just my opinion on that part