var mongoose = require('mongoose'),
    moment = require('moment');

var raceSchema = mongoose.Schema({
    challenger: String,
    opponent: String,
    route: {
        route: Array,
        created: Number
    },
    status: String,
    start: Number,
    end: Number,
    distance: Number,
    speed: Number,
    duration: Number,
    created: Number
});

module.exports = mongoose.model("Race", raceSchema);

var mongoose = require('mongoose'),
    moment = require('moment');

var raceSchema = mongoose.Schema({
    challenger: {
        username: String,
        start: Number,
        end: Number,
        speed: Number,
        duration: Number,
        route: {
            origin: {
                lat: Number,
                lng: Number
            },
            wayPoints: Array,
            created: Number
        }
    },
    opponent: {
        username: String,
        start: Number,
        end: Number,
        speed: Number,
        duration: Number,
        route: {
            origin: {
                lat: Number,
                lng: Number
            },
            wayPoints: Array,
            created: Number
        }
    },
    status: String,
    winner: String,
    created: Number
});

module.exports = mongoose.model("Race", raceSchema);

Change race schema