<?php
namespace App\Services\demo;

use App\Models\demo\mongo\User;

class MongoService
{
    public function addUser()
    {
        $user = User::getInstance();
        $data = [
            '_id' => 4,
            'name' => 'dw04',
            'mobile' => '17701340004'
        ];
        return $user->add($data);
    }

    public function addManyUser()
    {
        $user = User::getInstance();
        $data = [
            [
                '_id' => 5,
                'name' => 'dw05',
                'mobile' => '17701340005'
            ],
            [
                '_id' => 6,
                'name' => 'dw06',
                'mobile' => '17701340006'
            ]
        ];
        return $user->addMany($data);
    }

    public function deleteUser()
    {
        $user = User::getInstance();
        $params = [
            'name' => 'dw01'
        ];
        return $user->delete($params);
    }

    public function updateUser()
    {
        $user = User::getInstance();
        $params = [
            'name' =>  'dw02'
        ];
        $data = [
            'mobile' => '17701340002'
        ];
        return $user->update($params, $data);
    }

    public function getUser()
    {
        $user = User::getInstance();
        $params = [
            'name' =>  'dw02'
        ];
        return $user->get($params);
    }

    public function getManyUser()
    {
        $user = User::getInstance();
        $params = [
            'name' =>  'dw02'
        ];
        return $user->getMany($params);
    }
}
