{"size": 724, "ext": "js", "max_stars_repo_path": "controllers/orderController.js", "max_stars_repo_name": "LauraPorto/movieBackend", "max_stars_repo_stars_event_min_datetime": "2021-03-23T12:14:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-23T12:14:59.000Z", "max_issues_repo_path": "controllers/orderController.js", "max_issues_repo_name": "LauraPorto/movieBackend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/orderController.js", "max_forks_repo_name": "LauraPorto/movieBackend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.5675675676, "max_line_length": 54, "alphanum_fraction": 0.6298342541}
const mongoose = require('mongoose');
const Order = require("../models/order");


class OrderController {

    constructor() {

    };

    async rentFilm(order) {
        return Order.create(order);
    };

    async findOrderById(id) {
        return Order.findById(id);
    };

    async indexAllOrders(orderCollection) {
        return Order.find(orderCollection);
    };

    async updateOrder(id, order) {
        //return User.findByIdAndUpdate(id);
        const orderFound = Order.findOne({ _id: id });
        return orderFound.update(order);
    };

    async destroyOrder(id) {
        return Order.findByIdAndDelete(id);
    };
}



let orderController = new OrderController();
module.exports = orderController;