相关疑难解决方法(0)

使用mongoose在mongodb模式中使用ensureIndex

我想打电话ensureIndexauthorName,命令是什么,我应该把这个代码放在哪里?

var mongoose = require('mongoose');

// defines the database schema for this object
var schema = mongoose.Schema({
    projectName : String,
    authorName : String,
    comment : [{
        id : String,                                    
        authorName : String,
        authorEmailAddress : { type : String, index : true }    
    }]
});

// Sets the schema for model
var ProjectModel = mongoose.model('Project', schema);

// Create a project
exports.create = function (projectJSON) {
    var project = new ProjectModel({
        projectName : projectJSON.projectName,
        authorName : projectJSON.authorName,    

        comment …
Run Code Online (Sandbox Code Playgroud)

javascript indexing mongoose mongodb

8
推荐指数
2
解决办法
2万
查看次数

标签 统计

indexing ×1

javascript ×1

mongodb ×1

mongoose ×1