Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-348

Defined indexes in Mongoose aren't actually created?

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      I have a schema defining RSS feeds that looks like this:

          var feedSchema = new mongoose.Schema({
              feedURL: { type: String, trim:true, lowercase:true },
              link: { type: String, trim:true, lowercase:true },
              description: { type: String, trim:true },
              state: { type: String, trim:true, lowercase:true, default: 'new' },
              createdDate: { type: Date, default: Date.now },
              modifiedDate: { type: Date, default: Date.now },
          },
          { collection: 'feed' }
          );
          var FeedModel = mongoose.model( 'Feed', feedSchema );
      
          feedSchema.index({feedURL : 1}, {unique:true});
          feedSchema.index({link : 1}, {unique:true});
      

      According to the Mongoose docs it will run an ensureIndex at startup time. But this isn't happening. Neither of these indexes are defined. I tried dropping the collection and starting from nothing, but when I save the first document the only index defined is the one on _id.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            ctindel Chad Tindel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: