Database - OriginalTanks/tanks GitHub Wiki

#Database#

We use a Mongo DB to store the data. Node places information in the database and java backend accesses it and then places the game results back in.

##Schema##

Basically we have to main documents. Games and Users, you can see the schemas below.

Here is our Database Schema.

{
"Games": [Game];
"Users": [User];
"Game": {
        "name": String,
        "log": {"messages": [GameMessage]},
        "users": [GameUser],
        "tanks": [GameTank],
        "tankIds": [ObjectId],
        "board": [String](/OriginalTanks/tanks/wiki/String),
        "ready": Boolean,
        "status": Number
        };
        
"GameMessage": {
    "userName": String,
    "message": String
        };

"GameUser": {
    userId: ObjectId,
    userName: String,
    tankName: String,
    tankId: ObjectId
                };
"GameCoord": {
      x: Number,
      y: Number  
};

"GameTank": {
        coord: GameCoord,
        tankId: ObjectId,
        tankName: String
};

 "TankSchema": {
        name: String,
        code: String
};

"UserSchema" :{
        username: {type: String, index: true, unique: true},
        password_hash: String,
        tanks: [TankSchema]
};
}`