что делает useCreateIndex в mongo
что делает useCreateIndex в mongo
смотрел в документации не понял
Ответы (1 шт):
Автор решения: entithat
→ Ссылка
By default, Mongoose 5.x calls the MongoDB driver's ensureIndex() function. The MongoDB driver deprecated this function in favor of createIndex()
Как видим из документации Mongo:
createIndex(fieldOrSpec, options, callback)creates an index on the db and collection collection.
ensureIndex(fieldOrSpec, options, callback)ensures that an index exists, if it does not it creates it
Короче говоря, опция { useCreateIndex: true } заставляет mongoose использовать createIndex() вместо ensureIndex(), чтобы не было предупреждения о использовании выпиленных из Mongo фич.