Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET /rooms 需要更多的過濾條件 #224

Closed
JohnsonMao opened this issue Nov 10, 2024 · 2 comments · Fixed by #228
Closed

GET /rooms 需要更多的過濾條件 #224

JohnsonMao opened this issue Nov 10, 2024 · 2 comments · Fixed by #228
Assignees
Labels
enhancement New feature or request

Comments

@JohnsonMao
Copy link

需要新增的過濾條件

  • 針對房名、遊戲名模糊搜尋
  • 是否是私有房間
@ricksu978
Copy link
Member

MongoDb DbRef

在 Room table 中,遊戲是存成 DbRef,該如何 lookup ?

@kuoche1712003
Copy link
Contributor

我找到方法了
https://dev.to/saurabh73/mongodb-using-aggregation-pipeline-to-extract-dbref-using-lookup-operator-4ekl

[
  {
    $addFields: {
      game: {
        $arrayElemAt: [
          {
            $objectToArray: "$game"
          },
          1
        ]
      }
    }
  },
  {
    $lookup: {
      from: "gameRegistrationData",
      localField: "game.v",
      foreignField: "_id",
      as: "game"
    }
  },
  {
    $addFields: {
      game: {
        $arrayElemAt: ["$game", 0]
      }
    }
  }
]

但也太醜了吧 ...
這樣還不如查兩次?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants