如何使用猫鼬删除索引 [英] How to drop index using Mongoose

查看:58
本文介绍了如何使用猫鼬删除索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

猫鼬

Imagdata.dropIndexes( { "image_id": 1 }, function(err){
         if(err){
             res.send("error");
        }
        else{
            res.send("success");
        }
});

这是我用于删除字段"image_id"的索引的代码.当我尝试执行此功能时,它显示"TypeError:Imagdata.dropIndexes不是函数".如何解决此问题...

This is the code I used for remove the index of a field 'image_id'. When I trying to execute this function It shows "TypeError: Imagdata.dropIndexes is not a function". How to fix this issue...

推荐答案

您需要使用原始的

You need to use the raw collection property of your model to access the underlying MongoDB API:

Imagdata.collection.dropIndex(...);

这篇关于如何使用猫鼬删除索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆