modulepackage
0.1.3
Repository: https://github.com/sakura-rip/mongodb-gen.git
Documentation: pkg.go.dev
# README
mongodb-gen
The mongodb-gen tool produces a mongodb dao(data access object) from given go struct.
Installation
Download from release page
or using shell
go get -u github.com/sakura-rip/mongodb-gen
go install github.com/sakura-rip/mongodb-gen
Generate example
Here is sample dir
$ tree
D:.
├─sample
│ group.go
│ new.go
│ user.go
then
mongodb-gen sample
out:
$ tree /f
D:.
├─sample
│ group.go
│ new.go
│ user.go
│
├─sample_dao
│ client_gen.go
│ GroupCollectionBase_gen.go
│ GroupMembersField_gen.go
│ GroupNameField_gen.go
│ query.go
...etx
Usage of generated file
package main
import (
"fmt"
"github.com/sakura-rip/mongodb-gen/sample"
dao "github.com/sakura-rip/mongodb-gen/sample_dao"
"log"
)
func main() {
uuid := "39f436034ff548748229433587dce645"
userCl := dao.NewUserDaoClient()
_, err := userCl.InsertOne(&sample.User{
Id: uuid,
Email: "[email protected]",
Profile: sample.Profile{Name: "sakura"},
})
if err != nil {
log.Fatal("failed to insert user")
}
user, err := userCl.GetUserByProfileName("sakura")
if err != nil {
fmt.Printf("%#v\n", user)
}
}
read generated file to get more detail
# Functions
ExecCommand - コマンドを実行して出力結果とエラーを返す.
No description provided by the author
No description provided by the author
GetGitRootPath - カレントディレクトリが所属するGitリポジトリの直下のパスを返す.
GetGoModPath - Gitリポジトリ直下から幅優先探索でgo.modを探す.
GetGoRootPackageName - Goのルートパッケージ名をgo.modから取得する.
GetGoRootPath - go.modがあるフォルダを返す.
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author