Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
douyincloud-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何进财
douyincloud-service
Commits
9c9a2276
Commit
9c9a2276
authored
Aug 18, 2022
by
limenglei01
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:mongodb init value
parent
51c6aa35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
mongo.go
component/mongo.go
+12
-1
No files found.
component/mongo.go
View file @
9c9a2276
...
...
@@ -97,7 +97,18 @@ func NewMongoComponent() *mongoComponent {
fmt
.
Printf
(
"mongoClient init error. err %s
\n
"
,
err
)
panic
(
"mongo connect error"
)
}
return
&
mongoComponent
{
client
,
"demo"
}
dataBase
:=
"demo"
doc
:=
&
model
{
Key
:
"name"
,
Value
:
Mongo
,
}
_
,
err
=
client
.
Database
(
dataBase
)
.
Collection
(
collectionName
)
.
InsertOne
(
context
.
TODO
(),
doc
)
if
err
!=
nil
{
fmt
.
Printf
(
"mongoClient init error. err %s
\n
"
,
err
)
panic
(
"mongo init error"
)
}
return
&
mongoComponent
{
client
,
dataBase
}
}
//init 项目启动时,会从环境变量中获取mongodb的地址,用户名和密码
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment