arashsheyda / nuxt-mongoose

A Nuxt module for simplifying the use of Mongoose in your project.
https://docs.arashsheyda.me/nuxt-mongoose
75 stars 13 forks source link

how to index in schema or use mongoose plugins with shema via nuxt-mongoose #58

Open hoanghiep1x0 opened 4 months ago

hoanghiep1x0 commented 4 months ago

I used a hook but it doesn't seem to hit the index

 hooks(schema) {
        schema.index({ name: 'text' });
    }
arashsheyda commented 4 months ago

what about something like this:

schema: {
    email: {
      type: 'string',
      required: true,
      unique: true,
      index: true,
    },
  },

https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.index()