I
I
Ilya Magdenko2018-04-04 04:01:22
MongoDB
Ilya Magdenko, 2018-04-04 04:01:22

How to replace a specific entry in MongoDB?

Hello,
I am generating a map based on a table.
5ac422873b259475954759.png
When the user clicks on a cell, a symbol appears in it.

if (value === null) return (
  <td onClick={this.handleCellClick.bind(this, row, col)}></td>
);

Here, when clicked, the parameters of the cell are passed. Here:
handleCellClick(row, col) {
    let currentPlayer = this.currentPlayer(); // 1
    let game = this.props.game;
    game.board[row][col] = currentPlayer;
    Games.update(game._id, { $set: {board: game.board} });
  }

Register here for the database. After a few clicks, the database entry looks like this: -db.games.find()
5ac4235d50691520059378.png
How do I change all 1s to null on every click?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question