Indexes not sending to MongoDB
AuroPick opened this issue · 1 comments
AuroPick commented
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
I create a schema and creating some indexes they are created but not sending to MongoDB
my schema
paywall.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document } from 'mongoose'
export type PaywallDocument = Paywall & Document
@Schema({ timestamps: true })
export class Paywall {
@Prop({ type: String, enum: ['A/B', 'REGULAR'], required: true, default: 'REGULAR' })
type: 'A/B' | 'REGULAR'
@Prop({ type: String, unique: true, required: true })
name: string
@Prop({ type: Boolean, required: true, default: true })
enable: boolean
}
export const PaywallSchema = SchemaFactory.createForClass(Paywall)
PaywallSchema.index({ enable: 1 })
console.log(PaywallSchema.indexes())
I can log them in console
but not sending to MongoDB
Minimum reproduction code
maybe after
Steps to reproduce
No response
Expected behavior
They should be sended to MongoDB
Package version
9.2.0
mongoose version
6.5.2
NestJS version
9.0.11
Node.js version
18.6.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
AuroPick commented
I have had read preference: secondary preferred. I updated it to primary. Now it is works.
update
readPreference=secondaryPreferred
to
readPreference=primary