{"size": 583, "ext": "js", "max_stars_repo_path": "plant/plant-model.js", "max_stars_repo_name": "Water-My-Plant-2020/Back-End", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plant/plant-model.js", "max_issues_repo_name": "Water-My-Plant-2020/Back-End", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plant/plant-model.js", "max_forks_repo_name": "Water-My-Plant-2020/Back-End", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 15.3421052632, "max_line_length": 46, "alphanum_fraction": 0.615780446}
const db = require("../config")

function getPlants() {
    return db('plants')
}

function getPlantsByID(id) {
    return db('plants')
        .where({id})
        .first()
}

async function updatePlantsByID(id, changes) {
	await db("plants")
		.where({ id })
		.update(changes)

	return getPlantsByID(id)
}

function addPlant(newPlant) {
    return db('plants')
        .insert(newPlant)
}

function removePlant(id) {
    return db('plants')
        .where({ id })
        .del()
}

module.exports = {
	getPlants,
	getPlantsByID,
	updatePlantsByID,
    addPlant,
    removePlant,
}