//SetupIndexes sets up indexes for the given database.
SetupIndexes sets up indexes for the given database.
// SetupIndexes sets up indexes for the given database .
func SetupIndexes(c context.Context, d *mongo.Database) error {
	_, err := d.Collection("account").Indexes().CreateOne(c, mongo.IndexModel{
		Keys: bson.D{
			{
				Key: "open_id", Value: 1,
			},
		},
		Options: options.Index().SetUnique(true),
	})
	if err != nil {
		return err
	}
	_, err = d.Collection("trip").Indexes().CreateOne(c, mongo.IndexModel{
		Keys: bson.D{
			{Key: "trip.accountid", Value: 1},
			{Key: "trip.status", Value: 1},
		},
		Options: options.Index().SetUnique(true).SetPartialFilterExpression(bson.M{
			"trip.status": 1,
		}),
	})
	if err != nil {
		return err
	}
	_, err = d.Collection("profile").Indexes().CreateOne(c, mongo.IndexModel{
		Keys: bson.D{
			{Key: "accountid", Value: 1},
		},
		Options: options.Index().SetUnique(true),
	})
	return err
}
func SetupIndexes ( c context . Context , d * mongo . Database ) error { _ , err := d . Collection ( " " ) . Indexes ( ) . CreateOne ( c , mongo . IndexModel { Keys : bson . D { { Key : " " , Value : 1 , } , } , Options : options . Index ( ) . SetUnique ( true ) , } ) if err != nil { return err } _ , err = d . Collection ( " " ) . Indexes ( ) . CreateOne ( c , mongo . IndexModel { Keys : bson . D { { Key : " " , Value : 1 } , { Key : " " , Value : 1 } , } , Options : options . Index ( ) . SetUnique ( true ) . SetPartialFilterExpression ( bson . M { " " : 1 , } ) , } ) if err != nil { return err } _ , err = d . Collection ( " " ) . Indexes ( ) . CreateOne ( c , mongo . IndexModel { Keys : bson . D { { Key : " " , Value : 1 } , } , Options : options . Index ( ) . SetUnique ( true ) , } ) return err }
SetupIndexes sets up indexes for the given database.
SetupIndexes sets up indexes for the given database .