查询单挑记录后置方法
@param array $data
@return mixed
776106
public function __selectOneAfter(&$data, $linkOption)
	{
		foreach($this->bitFields as $field)
		{
			if(isset($data[$field]))
			{
				$data[$field] = (1 == $data[$field] || chr(1) == $data[$field]);
			}
		}
	}
300913
public function toRet(array $data = [])
    {
        if ($this->isSuccess()) {
            return $this->suc($data + (array) $this->getResponse());
        }

        $e = $this->getErrorException();
        return $this->err($data + ['code' => $e->getCode(), 'message' => $e->getMessage()]);
    }
650973
protected function getOrCreateObject(?array $data = null)
    {
        if ($data === null) {
            return null;
        }

        return $this->objectManager->getOrCreateObject(
            $this->getClassName(),
            $data
        );
    }
196694
public function collection(array $data = array())
    {
        $collection = trim(str_replace('\\', '_', $this->collection), '_');
        
        return $this->$collection()
            ->setDatabase($this)
            ->setModel($this->model)
            ->set($data);
    }
330315
public function convert( $data ) {
		if ( is_object($data) ) {
			$data = Helper::convert_wp_object($data);
		} else if ( is_array($data) ) {
			$func = __FUNCTION__;
			foreach ( $data as &$ele ) {
				if ( is_array($ele) ) {
					$ele = $this->$func($ele);
				} else if ( is_object($ele) ) {
					$ele = Helper::convert_wp_object($ele);
				}
			}
		}
		return $data;
	}
916227
public function update(array $data)
    {
        $where = [];
        $options = $this->parseExpress();
        $data    = array_merge($options['data'], $data);
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }
        $pk = $this->getPk();
        if (empty($options['where'])) {
            // 如果存在主键数据 则自动作为更新条件
            if (is_string($pk) && isset($data[$pk])) {
                $where[$pk] = $data[$pk];
                $key        = 'mongo:' . $options['table'] . '|' . $data[$pk];
                unset($data[$pk]);
            } elseif (is_array($pk)) {
                // 增加复合主键支持
                foreach ($pk as $field) {
                    if (isset($data[$field])) {
                        $where[$field] = $data[$field];
                    } else {
                        // 如果缺少复合主键数据则不执行
                        throw new Exception('miss complex primary data');
                    }
                    unset($data[$field]);
                }
            }
            if (!isset($where)) {
                // 如果没有任何更新条件则不执行
                throw new Exception('miss update condition');
            } else {
                $options['where']['$and'] = $where;
            }
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['$and'][$pk])) {
            $key = $this->getCacheKey($options['where']['$and'][$pk], $options);
        }

        // 生成bulkWrite对象
        $bulk         = $this->builder->update($data, $options);
        $writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : null;
        $writeResult  = $this->execute($options['table'], $bulk, $writeConcern);

        $result = $writeResult->getModifiedCount();
        if ($result) {
            if (isset($where[$pk])) {
                $data[$pk] = $where[$pk];
            } elseif (is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $data[$pk]     = $val;
            }
            $options['data'] = $data;
            $this->trigger('after_update', $options);
        }
        return $result;
    }
971851
public function updateIndexOne(array $data)
    {
        if (!is_array($data)) {
            throw new \Exception('你的索引参数不是一个数组');
        }

        if (count($data) == count($data, 1)) {
            // 一维数组
            $this->getIndex()->update(new \XSDocument($data));
        }

        //索引是否立即生效
        if ($this->flush_index) {
            $this->getIndex()->flushIndex();
        }

        return $this->getIndex();
    }
1176901
public function register($data)
    {
        // 1. 校验额外数据
        if (isset($data['mobile'])) {
            $validator = wei()->validate([
                'data' => $data,
                'rules' => [
                    'mobile' => [
                        'required' => true,
                        'mobileCn' => true,
                    ],
                    'verifyCode' => [
                        'required' => true,
                    ],
                ],
                'names' => [
                    'mobile' => '手机号码',
                    'verifyCode' => '验证码',
                ],
                'messages' => [
                    'mobile' => [
                        'required' => '请输入手机号码',
                    ],
                    'verifyCode' => [
                        'required' => '请输入验证码',
                    ],
                ],
            ]);
            if (!$validator->isValid()) {
                return ['code' => -1, 'message' => $validator->getFirstMessage()];
            }

            $ret = wei()->verifyCode->check($data['mobile'], $data['verifyCode']);
            if ($ret['code'] !== 1) {
                return $ret + ['verifyCodeErr' => true];
            }
        } else {
            $validator = wei()->validate([
                'data' => $data,
                'rules' => [
                    'email' => [
                        'required' => true,
                    ],
                ],
                'names' => [
                    'email' => '邮箱',
                ],
                'messages' => [
                    'email' => [
                        'required' => '请输入邮箱',
                    ],
                ],
            ]);
            if (!$validator->isValid()) {
                return ['code' => -1, 'message' => $validator->getFirstMessage()];
            }
        }

        // 2. 统一校验
        $validator = wei()->validate([
            'data' => $data,
            'rules' => [
                'email' => [
                    'required' => false,
                    'email' => true,
                    'notRecordExists' => ['user', 'email'],
                ],
                'password' => [
                    'minLength' => 6,
                ],
                'passwordConfirm' => [
                    'equalTo' => $data['password'],
                ],
            ],
            'names' => [
                'email' => '邮箱',
                'password' => '密码',
            ],
            'messages' => [
                'passwordConfirm' => [
                    'required' => '请再次输入密码',
                    'equalTo' => '两次输入的密码不相等',
                ],
            ],
        ]);
        if (!$validator->isValid()) {
            return ['code' => -7, 'message' => $validator->getFirstMessage()];
        }

        if ($data['mobile']) {
            $user = wei()->user()->mobileVerified()->find(['mobile' => $data['mobile']]);
            if ($user) {
                return ['code' => -8, 'message' => '手机号码已存在'];
            }
        }

        $ret = $this->event->until('userRegisterValidate', [$this]);
        if ($ret) {
            return $ret;
        }

        // 3. 保存到数据库
        $this->setPlainPassword($data['password']);

        if ($data['mobile']) {
            $this->setMobileVerified();
        }

        $this->save([
            'email' => (string) $data['email'],
            'mobile' => (string) $data['mobile'],
            'username' => (string) $data['username'],
            'source' => isset($data['source']) ? $data['source'] : '',
        ]);

        return ['code' => 1, 'message' => '注册成功'];
    }
194486
public function updateData($data)
    {
        $isMobileVerified = $this->isMobileVerified();

        $validator = wei()->validate([
            'data' => $data,
            'rules' => [
                'mobile' => [
                    'required' => !$isMobileVerified,
                    'mobileCn' => true,
                ],
                'name' => [
                    'required' => false,
                ],
                'address' => [
                    'required' => false,
                    'minLength' => 3,
                ],
            ],
            'names' => [
                'mobile' => '手机号码',
                'name' => '姓名',
                'address' => '详细地址',
            ],
        ]);
        if (!$validator->isValid()) {
            return $this->err($validator->getFirstMessage());
        }

        if (!$isMobileVerified) {
            // 手机号未认证时,检查手机号,根据配置检查是否重复
            if (wei()->setting('user.check_mobile_unique') && $this->isMobileExists($data['mobile'])) {
                return $this->err('手机号码已存在');
            }
            $this['mobile'] = $data['mobile'];
        }

        $result = $this->event->until('preUserUpdate', [$data, $this]);
        if ($result) {
            return $result;
        }

        $this->save([
            'name' => $data['name'],
            'address' => $data['address'],
        ]);

        return $this->suc();
    }
201862
protected function setIdFromData(array $data)
    {
        $key = $this->key();
        if (isset($data[$key])) {
            $this->setId($data[$key]);
            unset($data[$key]);
        }

        return $data;
    }
474814
public function select($data = null)
    {
        if ($data instanceof MongoQuery) {
            return $data->select();
        } elseif ($data instanceof \Closure) {
            call_user_func_array($data, [ & $this]);
            $data = null;
        }
        // 分析查询表达式
        $options = $this->parseExpress();

        if (!is_null($data)) {
            // 主键条件分析
            $this->parsePkWhere($data, $options);
        }

        // 生成MongoQuery对象
        $query = $this->builder->select($options);

        $options['data'] = $data;
        if ($resultSet = $this->trigger('before_select', $options)) {
        } else {
            // 执行查询操作
            $readPreference = isset($options['readPreference']) ? $options['readPreference'] : null;
            $resultSet      = $this->query($options['table'], $query, $readPreference, $options['fetch_cursor'], $options['typeMap']);

            if ($resultSet instanceof Cursor) {
                // 返回MongoDB\Driver\Cursor对象
                return $resultSet;
            }
        }
        return $resultSet;
    }
732382
public function filter(array $data)
    {
        $filteredData = [];

        foreach ($data as $value) {
            if ($this->match($value)) {
                $filteredData[] = $value;
            }
        }

        return $filteredData;
    }
369268
public function factory(array $data = [])
    {
        $model = $this->newQuery()->getModel()->newInstance();

        $this->setModelData($model, $data);

        return $model;
    }
23104
public function resolveArray(array $data)
    {
        $self = $this;
        array_walk_recursive($data, function (&$value, $key) use ($self) {
            if (is_string($value)) {
                $value = $self->resolveString($value);
            }
        });

        return $data;
    }
969600
public function transform($data)
    {
        if (is_array($data)) {
            return $data;
        }

        if (is_object($data) && $data instanceof Arrayable) {
            return $data->toArray();
        }

        return (array) $data;
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
329287
public function set($data)
    {
        $this->error = [];
        $result = null;
        switch ($this->format) {
            case 'nvp':
                parse_str($data, $this->data);
                $result = !empty($this->data);
                break;

            case 'json':
            default:
                $this->data = empty($data) ? [] : (json_decode($data, true) ?: []);
                $result = json_last_error() == JSON_ERROR_NONE;
                if (empty ($result)) {
                    $this->error = [
                        'error' => json_last_error(),
                        'msg'   => json_last_error_msg(),
                    ];
                }
                break;
        }

        return $result;
    }