Slide 28
Slide 28 text
.findAndModify(
{number_of_players: {$lt:5}, pid: process.pid},
[],
{$inc: {number_of_players: 1}, $push:{players:connection.connectionId}},
{new:true, upsert:false},
function(err, board) {
// Code to deal with the board or the non existance of the board
}
Initializing a board
•Using findAndModify to pick a
board
•Atomic operation to add player
to existing board
•Process bound
Friday, July 6, 12