Skip to content

Commit f5adc98

Browse files
author
Amit
committed
Renamed repository package and Updated Readme
1 parent 1d9e21e commit f5adc98

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Readme.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ func CreateCollections(config *config.Config) {
8787
}
8888
```
8989

90+
### Create Unique Index
91+
92+
```go
93+
func CreateIndex() {
94+
mongodb_client.CreateUniqueIndex("dbName", "collectionName", "emailId")
95+
}
96+
```
97+
98+
### Create Index
99+
100+
```go
101+
func CreateIndex() {
102+
// For Single Field
103+
indexModel := mongo.IndexModel{
104+
Keys: bson.M{"YOUR_FIELD_NAME": 1},
105+
Options: options.Index().SetUnique(true),
106+
}
107+
108+
// For Multiple Fields
109+
indexModel := mongo.IndexModel{
110+
Keys: bson.M{"YOUR_FIELD_NAME": 1, "ANOTHER_FIELD_NAME": 1},
111+
Options: options.Index().SetUnique(true),
112+
}
113+
114+
mongodb_client.CreateIndex("YOUR_DB_NAME", "YOUR_COLLECTION_NAME", indexModel)
115+
}
116+
```
117+
90118
## 📦 Usage of Base Model and Repository Functions
91119

92120
### 📦 Base DML Model

0 commit comments

Comments
 (0)