-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Jav Service Data Model and MongoDB Integration
Here is a high-level summary of the commit in imperative bullet points: - Fix critical issues with the Jav service's data model infrastructure by introducing a new `model` package and rebalancing the database connection setup. - Enhance the Jav service's robustness with reconnect logic for the Mongo database. - Add a custom `Actress` struct and a new `Movie` data structure to the Jav service's data model. - Improve the overall scalability and reliability of the Jav service.
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package model | ||
|
||
import "go.mongodb.org/mongo-driver/bson/primitive" | ||
|
||
type Actress struct { | ||
ID primitive.ObjectID `bson:"_id,omitempty" json:"mongo_id"` | ||
Name string `bson:"name" json:"name"` | ||
NameEnglish string `bson:"name_english" json:"name_english"` | ||
URL string `bson:"url" json:"url"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Package model is a package for defining the data model for the jav service. | ||
package model | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/Laisky/errors/v2" | ||
|
||
"github.com/Laisky/laisky-blog-graphql/library/db/mongo" | ||
) | ||
|
||
// NewJavDB create new db | ||
func NewJavDB(ctx context.Context, info mongo.DialInfo) (db mongo.DB, err error) { | ||
db, err = mongo.NewDB(ctx, info) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "dial jav db") | ||
} | ||
|
||
return db, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package model | ||
|
||
import "go.mongodb.org/mongo-driver/bson/primitive" | ||
|
||
type Movice struct { | ||
ID primitive.ObjectID `bson:"_id,omitempty" json:"mongo_id"` | ||
ActressID primitive.ObjectID `bson:"actress_id" json:"actress_id"` | ||
Description string `bson:"description" json:"description"` | ||
ImgUrl string `bson:"img_url" json:"img_url"` | ||
Name string `bson:"name" json:"name"` | ||
Tags []string `bson:"tags" json:"tags"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters