빈 디비에서 첫 실행할 때 문제 수정

This commit is contained in:
2023-06-21 18:14:44 +09:00
parent 9fd2316eeb
commit 1b90e12fec
2 changed files with 12 additions and 2 deletions

View File

@ -303,6 +303,12 @@ func (caller apiCaller) serviceAPI(w http.ResponseWriter, r *http.Request) error
return err
}
if len(service.ServerApiTokens) == 0 {
service.ServerApiTokens = []primitive.ObjectID{
primitive.NewObjectIDFromTimestamp(time.Now().Add(-time.Hour * 24 * 30 * 465)),
}
}
filter := bson.M{"_id": service.Id}
success, _, err := mg.mongoClient.Update(CollectionService, filter, bson.M{
"$set": &service,
@ -335,7 +341,7 @@ func (caller apiCaller) maintenanceAPI(w http.ResponseWriter, r *http.Request) e
}
_, _, err := mg.mongoClient.Update(CollectionService, bson.M{
"_Id": mg.service().Id,
"_id": mg.service().Id,
}, bson.M{
"$set": bson.M{"divisions": divs},
}, options.Update().SetUpsert(false))