did mongodb 4.2 fix upsert duplicate key? - closes #7841
parent
30bf5c44a1
commit
3c90dd78f8
|
@ -35,7 +35,6 @@ final class ActivityWriteApi(
|
|||
_ <-
|
||||
(!setters.isEmpty) ?? coll.update
|
||||
.one($id(a.id), $set(setters), upsert = true)
|
||||
.recover(ignoreDuplicateKey)
|
||||
.void
|
||||
} yield ()
|
||||
}
|
||||
|
@ -52,7 +51,6 @@ final class ActivityWriteApi(
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(ignoreDuplicateKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +68,6 @@ final class ActivityWriteApi(
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(ignoreDuplicateKey)
|
||||
}
|
||||
|
||||
def learn(userId: User.ID, stage: String) =
|
||||
|
@ -151,8 +148,7 @@ final class ActivityWriteApi(
|
|||
|
||||
private def get(userId: User.ID) = coll.byId[Activity, Id](Id today userId)
|
||||
private def getOrCreate(userId: User.ID) = get(userId) map { _ | Activity.make(userId) }
|
||||
private def save(activity: Activity) =
|
||||
coll.update.one($id(activity.id), activity, upsert = true).void.recover(ignoreDuplicateKey)
|
||||
private def save(activity: Activity) = coll.update.one($id(activity.id), activity, upsert = true).void
|
||||
private def update(userId: User.ID)(f: Activity => Option[Activity]): Funit =
|
||||
getOrCreate(userId) flatMap { old =>
|
||||
f(old) ?? save
|
||||
|
|
|
@ -14,7 +14,7 @@ final class LearnApi(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext)
|
|||
coll.one[LearnProgress]($id(user.id)) dmap { _ | LearnProgress.empty(LearnProgress.Id(user.id)) }
|
||||
|
||||
private def save(p: LearnProgress): Funit =
|
||||
coll.update.one($id(p.id), p, upsert = true).void.recover(lila.db.ignoreDuplicateKey)
|
||||
coll.update.one($id(p.id), p, upsert = true).void
|
||||
|
||||
def setScore(user: User, stage: String, level: Int, score: StageProgress.Score) =
|
||||
get(user) flatMap { prog =>
|
||||
|
|
|
@ -31,7 +31,6 @@ final class PrefApi(
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(lila.db.ignoreDuplicateKey)
|
||||
else
|
||||
coll.update
|
||||
.one($id(user.id), $unset(s"tags.${tag(Pref.Tag)}"))
|
||||
|
@ -69,7 +68,7 @@ final class PrefApi(
|
|||
}
|
||||
|
||||
def setPref(pref: Pref): Funit =
|
||||
coll.update.one($id(pref.id), pref, upsert = true).void.recover(lila.db.ignoreDuplicateKey) >>-
|
||||
coll.update.one($id(pref.id), pref, upsert = true).void >>-
|
||||
cache.put(pref.id, fuccess(pref.some))
|
||||
|
||||
def setPref(user: User, change: Pref => Pref): Funit =
|
||||
|
|
|
@ -43,7 +43,6 @@ final class WebSubscriptionApi(coll: Coll)(implicit ec: scala.concurrent.Executi
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(lila.db.ignoreDuplicateKey)
|
||||
|
||||
def unsubscribeBySession(sessionId: String): Funit = {
|
||||
coll.delete.one($id(sessionId)).void
|
||||
|
|
|
@ -107,7 +107,6 @@ final private class RelationRepo(coll: Coll, userRepo: lila.user.UserRepo)(impli
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(lila.db.ignoreDuplicateKey)
|
||||
|
||||
def remove(u1: ID, u2: ID): Funit = coll.delete.one($id(makeId(u1, u2))).void
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ final class ShutupApi(
|
|||
case None => fufail(s"can't find user record for $userId")
|
||||
case Some(userRecord) => legiferate(userRecord)
|
||||
}
|
||||
.recover(lila.db.ignoreDuplicateKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ final class RankingApi(
|
|||
upsert = true
|
||||
)
|
||||
.void
|
||||
.recover(lila.db.ignoreDuplicateKey)
|
||||
|
||||
def remove(userId: User.ID): Funit =
|
||||
userRepo byId userId flatMap {
|
||||
|
|
Loading…
Reference in New Issue