<?php


namespace Api\PhpServices\ThumbsUp\models;


use Api\PhpUtils\Mongo\Base;

class ThumbsUp extends Base
{

    protected static $instance;


    protected function getConfigIndex()
    {
        return "thumbsup";
    }


    protected function getCollectionName()
    {
        return "data";
    }

    protected function getWhere($params)
    {
        return $params;
    }

    protected function getQueryOptions($fields = [], $sort = [], $limit = [])
    {
        $options = [
            'maxTimeMS' => 800,
            'limit' => 100
        ];
        if (is_array($fields) && !empty($fields)) {
            $options['projection'] = $fields;
        }
        if (is_array($sort) && !empty($sort)) {
            $options['sort'] = $sort;
        }
        if (is_array($limit)) {
            if (isset($limit['start'])) {
                $options['skip'] = intval($limit['start']);
            }
            if (isset($limit['count'])) {
                $options['limit'] = intval($limit['count']);
            }
        }
        return $options;
    }
}
