{"size": 601, "ext": "js", "max_stars_repo_path": "api/services/TeamService.js", "max_stars_repo_name": "mcappleman/mlb_feed", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/services/TeamService.js", "max_issues_repo_name": "mcappleman/mlb_feed", "max_issues_repo_issues_event_min_datetime": "2017-04-06T16:30:34.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-06T17:01:18.000Z", "max_forks_repo_path": "api/services/TeamService.js", "max_forks_repo_name": "mcappleman/mlb_feed", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 13.0652173913, "max_line_length": 65, "alphanum_fraction": 0.5956738769}
'use strict'

var request = require('request');
var Team = require('../models/Team');

module.exports = {
	create,
	find,
	findOne,
	findOrCreate
}

function create(team) {

	return Team.create(team);

}

function find(query) {

	return Team.find(query);

}

function findOne(query) {

	return Team.findOne(query);

}

function findOrCreate(abbrev, city, name) {

	return Team.findOne({ abbrev: abbrev, city: city, name: name })
	.then((team) => {

		if (!team) {

			return create({ abbrev: abbrev, city: city, name: name });

		}

		return team;

	});

}