Note that there are some explanatory texts on larger screens.

plurals
  1. POMongoDB find user not in array
    primarykey
    data
    text
    <p>I'm currently developing a multiplayer card game with a node.js + mongodb backend. I want users to be able to join games so I'm implementing a queue function. In this queue function I want to be able to get a single game from mongodb that is not started, not locked and doesn't contain the player in the queue.</p> <p>Example of my mongodb game document:</p> <pre><code>{ "_id": { "$oid": "512cccf9e4b09000a6f1f079" }, "mChanceTaken": false, "mCurrentPlayer": 0, "mCurrentPlayerName": "-", "mDeck": [ { "mValue": 13, "mSuit": "HEARTS" }, { "mValue": 13, "mSuit": "SPADES" }, { "mValue": 3, "mSuit": "SPADES" }, { "mValue": 10, "mSuit": "SPADES" }, { "mValue": 11, "mSuit": "CLUBS" }, { "mValue": 3, "mSuit": "HEARTS" }, { "mValue": 7, "mSuit": "DIAMONDS" }, { "mValue": 9, "mSuit": "SPADES" }, { "mValue": 8, "mSuit": "HEARTS" } ], "mFinished": false, "mLocked": false, "mNumberOfPlayers": 4, "mPlayers": [ { "mPlayerId": "512bd9a1e4b09000a6f1f073", "mUsername": "user2", "mPosition": 0, "mSwitching": true, "mFaceUp": [], "mFaceDown": [], "mHand": [] }, { "mPlayerId": "512bcb3be4b09000a6f1f06b", "mUsername": "user1", "mPosition": 0, "mSwitching": true, "mFaceUp": [], "mFaceDown": [], "mHand": [] } ], "mRoundLength": 60, "mStarted": false, "mSwitching": false </code></pre> <p>}</p> <p>My current query looks like this:</p> <pre><code>GameBoard.findOneAndUpdate({mStarted: false, mLocked: false, mPlayers: {$not: {mPlayerId: player.mPlayerId}}}, {mLocked: true}, function (err, gameBoard) { </code></pre> <p>I think I should use the $not operator but I can not figure out how to use it in my use case. please someone help me!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload