Skip to content

Commit 9558004

Browse files
committed
Update readme
1 parent cde878b commit 9558004

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

README.md

+41-4
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,61 @@
33
44
## Usage
55
```shell
6-
$ index --config <json config file> --uri <mongo database uri>
6+
$ indexer --config <json config file> --uri <mongo database uri>
77
```
88
Below is the description of all the accepted options
99
- `--apply` not required, to apply the index changes
10-
- `--config` required, path to json file containing the each collection index
10+
- `--config` required, path to json file containing the each collection index. This json file should be in this [format](https://gist.github.com/Idnan/71e0478985a3aefa88f6502f83b28056#file-go-mongo-indexer-format-json)
1111
- `--uri` required, mongo database uri
1212

13+
## Json Format
14+
The config json file that you will pass to `--config` flag to index the database collection should be in specific format. This file is an array of objects. Where each object has details like collection name, cap size and indexes for this specific collection.
15+
```
16+
[
17+
{
18+
"collection": "collection_name",
19+
"cap": null,
20+
"index": [
21+
["cartId"],
22+
["-status"],
23+
["orderId"],
24+
["groupId"],
25+
["currency"]
26+
["-createdAt"],
27+
["orderNumber", "type"],
28+
["-type", "-paymentStatus", "-payment.paymentMethod"],
29+
]
30+
},
31+
{
32+
"collection": "collection_name",
33+
"cap": null,
34+
"index": [
35+
["-userId"]
36+
["username"],
37+
["-createdAt", "-user.email"],
38+
]
39+
}
40+
....
41+
....
42+
....
43+
]
44+
```
45+
46+
- `Collection` is the collection name
47+
- `cap` collection cap size in bytes (not yet supported)
48+
- `index` array of indexes `-` sign before a column refers to the descending order and no sign before column name refers to the ascending order
49+
1350
## Examples
1451

1552
> See list of index changes before applying
1653
```shell
17-
$ index --config "xyz.json" --uri "mongodb://127.0.0.1:27017/database_name"
54+
$ indexer --config "xyz.json" --uri "mongodb://127.0.0.1:27017/database_name"
1855

1956
```
2057

2158
> Apply the index changes
2259
```shell
23-
$ index --config "xyz.json" --uri "mongodb://127.0.0.1:27017/database_name" --apply
60+
$ indexer --config "xyz.json" --uri "mongodb://127.0.0.1:27017/database_name" --apply
2461
```
2562

2663
## Todo
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/build-local.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set -o pipefail
77
export CGO_ENABLED=0
88
my_dir="$(dirname "$0")"
99

10-
go build -o ${my_dir}/../bin/index cmd/index/*.go
10+
go build -o ${my_dir}/../bin/indexer cmd/indexer/*.go

0 commit comments

Comments
 (0)