From 97619d483af58f262749c2e7290c40e3b0447094 Mon Sep 17 00:00:00 2001 From: Surawich Laprattanatrai Date: Tue, 31 Oct 2023 22:21:46 +0700 Subject: [PATCH] Update documents and examples --- CONTRIBUTING.md | 10 +++++ .../complex-query/user_comparator_repo.go | 41 ++++++++++++++----- examples/getting-started/user_repo.go | 2 +- main.go | 2 +- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c2a005f..82a6d80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,3 +70,13 @@ func doSomething(a, b, c) (d, ``` If the function definition spans multiple lines, the function body should start with an empty line to help distinguishing two elements. + +## Releasing Steps + +1. Make sure the dependencies are up to date +2. Make sure the examples are generated by the latest version +3. Make sure the README.md file reflects the current release +4. Remove `-next` from version variable in `main.go` +5. Create a git tag `vX.X.X` and push to GitHub +6. Run `goreleaser release` with GitHub token provided as an environment variable `GITHUB_TOKEN` +7. Bump version with `-next` suffix in version variable in `main.go` diff --git a/examples/complex-query/user_comparator_repo.go b/examples/complex-query/user_comparator_repo.go index 1a5b5ae..e9f2bcf 100644 --- a/examples/complex-query/user_comparator_repo.go +++ b/examples/complex-query/user_comparator_repo.go @@ -31,7 +31,9 @@ func (r *UserComparatorRepositoryMongo) FindByUsername(arg0 context.Context, arg func (r *UserComparatorRepositoryMongo) FindByAgeGreaterThan(arg0 context.Context, arg1 int) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "age": bson.M{"$gt": arg1}, + "age": bson.M{ + "$gt": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -45,7 +47,9 @@ func (r *UserComparatorRepositoryMongo) FindByAgeGreaterThan(arg0 context.Contex func (r *UserComparatorRepositoryMongo) FindByAgeGreaterThanEqual(arg0 context.Context, arg1 int) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "age": bson.M{"$gte": arg1}, + "age": bson.M{ + "$gte": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -59,7 +63,9 @@ func (r *UserComparatorRepositoryMongo) FindByAgeGreaterThanEqual(arg0 context.C func (r *UserComparatorRepositoryMongo) FindByAgeLessThan(arg0 context.Context, arg1 int) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "age": bson.M{"$lt": arg1}, + "age": bson.M{ + "$lt": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -73,7 +79,9 @@ func (r *UserComparatorRepositoryMongo) FindByAgeLessThan(arg0 context.Context, func (r *UserComparatorRepositoryMongo) FindByAgeLessThanEqual(arg0 context.Context, arg1 int) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "age": bson.M{"$lte": arg1}, + "age": bson.M{ + "$lte": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -87,7 +95,10 @@ func (r *UserComparatorRepositoryMongo) FindByAgeLessThanEqual(arg0 context.Cont func (r *UserComparatorRepositoryMongo) FindByAgeBetween(arg0 context.Context, arg1 int, arg2 int) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "age": bson.M{"$gte": arg1, "$lte": arg2}, + "age": bson.M{ + "$gte": arg1, + "$lte": arg2, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -101,7 +112,9 @@ func (r *UserComparatorRepositoryMongo) FindByAgeBetween(arg0 context.Context, a func (r *UserComparatorRepositoryMongo) FindByCityNot(arg0 context.Context, arg1 string) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "city": bson.M{"$ne": arg1}, + "city": bson.M{ + "$ne": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -115,7 +128,9 @@ func (r *UserComparatorRepositoryMongo) FindByCityNot(arg0 context.Context, arg1 func (r *UserComparatorRepositoryMongo) FindByCityIn(arg0 context.Context, arg1 []string) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "city": bson.M{"$in": arg1}, + "city": bson.M{ + "$in": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -129,7 +144,9 @@ func (r *UserComparatorRepositoryMongo) FindByCityIn(arg0 context.Context, arg1 func (r *UserComparatorRepositoryMongo) FindByCityNotIn(arg0 context.Context, arg1 []string) ([]*UserModel, error) { cursor, err := r.collection.Find(arg0, bson.M{ - "city": bson.M{"$nin": arg1}, + "city": bson.M{ + "$nin": arg1, + }, }, options.Find().SetSort(bson.M{})) if err != nil { return nil, err @@ -172,7 +189,9 @@ func (r *UserComparatorRepositoryMongo) FindByBannedFalse(arg0 context.Context) func (r *UserComparatorRepositoryMongo) FindByContactExists(arg0 context.Context) (*UserModel, error) { var entity UserModel if err := r.collection.FindOne(arg0, bson.M{ - "contact": bson.M{"$exists": 1}, + "contact": bson.M{ + "$exists": 1, + }, }, options.FindOne().SetSort(bson.M{})).Decode(&entity); err != nil { return nil, err } @@ -182,7 +201,9 @@ func (r *UserComparatorRepositoryMongo) FindByContactExists(arg0 context.Context func (r *UserComparatorRepositoryMongo) FindByContactNotExists(arg0 context.Context) (*UserModel, error) { var entity UserModel if err := r.collection.FindOne(arg0, bson.M{ - "contact": bson.M{"$exists": 0}, + "contact": bson.M{ + "$exists": 0, + }, }, options.FindOne().SetSort(bson.M{})).Decode(&entity); err != nil { return nil, err } diff --git a/examples/getting-started/user_repo.go b/examples/getting-started/user_repo.go index a47da5e..91e9d9f 100644 --- a/examples/getting-started/user_repo.go +++ b/examples/getting-started/user_repo.go @@ -49,7 +49,7 @@ func (r *UserRepositoryMongo) UpdateDisplayNameByID(arg0 context.Context, arg1 s if err != nil { return false, err } - return result.MatchedCount > 0, err + return result.MatchedCount > 0, nil } func (r *UserRepositoryMongo) DeleteByCity(arg0 context.Context, arg1 string) (int, error) { diff --git a/main.go b/main.go index 0f7fd75..028b852 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ const usageText = `repogen generates MongoDB repository implementation from repo Supported options:` // version indicates the version of repogen. -const version = "v0.3" +const version = "v0.4-next" func main() { flag.Usage = printUsage