Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • T TDDD27_help
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Insights
    • Issue
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Erik Berglund
  • TDDD27_help
  • Issues
  • #154
Closed
Open
Issue created May 25, 2022 by Miranda Alvenkrona@miral439

Update field in array in mongoose

Hi, we are having trouble with updating a field in our database. We have a collection Game that consist of player1, player2, deck1, and deck2. Deck1 and deck2 are arrays with objects, where each object has an _id, name, link, and bool. image

We want to update the bool field (to false) for a specific Game and specific object in deck1. We have the Game _id (roomId) and object _id (cardId). We have tried different solutions but none have worked. We think we should use findOneAndUpdate() or updatOne() but we can't figur out how to specify which card to change in deck1. Here is our latest try, which return null (both cardID and RoomId is correct, eg same as in the database). image

Edited May 25, 2022 by Miranda Alvenkrona
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking