This commit is contained in:
tengge 2020-05-13 21:01:04 +08:00
parent 610238d6e1
commit d5cc84d043
4 changed files with 26 additions and 12 deletions

View File

@ -35,7 +35,7 @@ require (
github.com/prometheus/common v0.9.1
github.com/ramya-rao-a/go-outline v0.0.0-20200117021646-2a048b4510eb // indirect
github.com/rogpeppe/godef v1.1.2 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/slimsag/godocmd v0.0.0-20161025000126-a1005ad29fe3 // indirect
github.com/sourcegraph/ctxvfs v0.0.0-20180418081416-2b65f1b1ea81 // indirect
@ -58,7 +58,7 @@ require (
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 // indirect
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c // indirect
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770 // indirect
golang.org/x/tools/gopls v0.4.0 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect

View File

@ -450,6 +450,8 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e h1:hq86ru83GdWTlfQFZGO4nZJTU
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c h1:kISX68E8gSkNYAFRFiDU8rl5RIn1sJYKYb/r2vMLDrU=
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

22
server/server/Mongo.go Normal file
View File

@ -0,0 +1,22 @@
// Copyright 2017-2020 The ShadowEditor Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//
// For more information, please visit: https://github.com/tengge1/ShadowEditor
// You can also visit: https://gitee.com/tengge1/ShadowEditor
package server
import (
"fmt"
"github.com/tengge1/shadoweditor/helper"
)
// Mongo create a new mongo client.
func Mongo() (*helper.Mongo, error) {
if Config == nil {
return nil, fmt.Errorf("config is not initialized")
}
return helper.NewMongo(Config.Database.Connection, Config.Database.Database)
}

View File

@ -8,8 +8,6 @@
package server
import (
"fmt"
"github.com/tengge1/shadoweditor/helper"
)
@ -40,11 +38,3 @@ func Create(path string) error {
return nil
}
// Mongo create a new mongo client.
func Mongo() (*helper.Mongo, error) {
if Config == nil {
return nil, fmt.Errorf("config is not initialized")
}
return helper.NewMongo(Config.Database.Connection, Config.Database.Database)
}