Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
231f148103
  1. 8
      internal/storage/mongo/jobs.go

8
internal/storage/mongo/jobs.go

@ -21,13 +21,13 @@ func (ms *mongoStorage) ValidateJob(_ *jw.Job) error {
}
func (ms *mongoStorage) InsertJob(job *jw.Job) (bool, error) {
collection := ms.Collection("jobs")
col := ms.Collection("jobs")
ctx, cancel := util.CtxWithTimeout(5 * time.Second)
defer cancel()
if job.Category == nil {
_, err := collection.InsertOne(ctx, job)
_, err := col.InsertOne(ctx, job)
if err != nil {
return false, err
}
@ -45,7 +45,7 @@ func (ms *mongoStorage) InsertJob(job *jw.Job) (bool, error) {
result, err := session.WithTransaction(
ctx,
func(ctx mongo.SessionContext) (interface{}, error) {
err := collection.FindOne(
err := col.FindOne(
ctx,
bson.M{
"category": *job.Category,
@ -63,7 +63,7 @@ func (ms *mongoStorage) InsertJob(job *jw.Job) (bool, error) {
return false, err
}
_, err = collection.InsertOne(ctx, job)
_, err = col.InsertOne(ctx, job)
if err != nil {
return false, err
}

Loading…
Cancel
Save