Mongolid\ActiveRecord::firstOrNew PHP Метод

firstOrNew() публичный статический Метод

Gets the first entity of this kind that matches the query. If no document was found, a new entity will be returned with the _if field filled.
public static firstOrNew ( mixed $id ) : ActiveRecord
$id mixed Document id.
Результат ActiveRecord
    public static function firstOrNew($id)
    {
        if ($entity = self::getDataMapperInstance()->first($id)) {
            return $entity;
        }
        $entity = new static();
        $entity->_id = $id;
        return $entity;
    }