feat: add otp implementation for mongodb

This commit is contained in:
Lakhan Samani
2022-07-23 16:01:46 +05:30
parent f6c67243b9
commit 1a27d91957
3 changed files with 42 additions and 4 deletions

View File

@@ -110,6 +110,15 @@ func NewProvider() (*provider, error) {
},
}, options.CreateIndexes())
mongodb.CreateCollection(ctx, models.Collections.OTP, options.CreateCollection())
otpCollection := mongodb.Collection(models.Collections.OTP, options.Collection())
otpCollection.Indexes().CreateMany(ctx, []mongo.IndexModel{
{
Keys: bson.M{"email": 1},
Options: options.Index().SetUnique(true).SetSparse(true),
},
}, options.CreateIndexes())
return &provider{
db: mongodb,
}, nil