package svc import ( "app-cloudep-tweeting-service/internal/config" model "app-cloudep-tweeting-service/internal/model/mongo" "fmt" ) func mustMongoConnectUrl(c config.Config) string { return fmt.Sprintf("%s://%s:%s", c.Mongo.Schema, c.Mongo.Host, c.Mongo.Port, ) } // TODO 思考快取做在那邊 func MustPostModel(c config.Config) model.PostModel { postCollection := model.Post{} return model.NewPostModel(mustMongoConnectUrl(c), c.Mongo.Database, postCollection.CollectionName()) } func MustCommentModel(c config.Config) model.CommentModel { m := model.Comment{} return model.NewCommentModel(mustMongoConnectUrl(c), c.Mongo.Database, m.CollectionName()) }