Skip to content

Storing Geodata not working #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
felixklemm opened this issue Jun 14, 2016 · 3 comments
Closed

Storing Geodata not working #865

felixklemm opened this issue Jun 14, 2016 · 3 comments

Comments

@felixklemm
Copy link

Hey, im trying to store Geodata in the GeoJSON-format. This post ist related to the following post:
#371

Unfortunately i'm getting an error, when trying to run the created migrate file.

Migration file: 2016_06_14_152201_create_restaurants_table.php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRestaurantsTable extends Migration
{
    public function up()
    {
        Schema::collection('restaurants_collection', function($table)
        {
            $table->index(array('location' => '2dsphere'));
        });
    }

    public function down()
    {
    }
}

Error:

 [MongoDB\Exception\InvalidArgumentException]  
  $collectionName is invalid: 

Stack trace:

[2016-06-14 15:47:01] lumen.ERROR: MongoDB\Exception\InvalidArgumentException: $collectionName is invalid:  in /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/mongodb/mongodb/src/Collection.php:88
Stack trace:
#0 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/mongodb/mongodb/src/Database.php(264): MongoDB\Collection->__construct(Object(MongoDB\Driver\Manager), 'test', NULL, Array)
#1 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(89): MongoDB\Database->selectCollection(NULL)
#2 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Blueprint.php(39): Jenssegers\Mongodb\Connection->getCollection(NULL)
#3 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(139): Jenssegers\Mongodb\Schema\Blueprint->__construct(Object(Jenssegers\Mongodb\Connection), NULL)
#4 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(109): Jenssegers\Mongodb\Schema\Builder->createBlueprint(NULL)
#5 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/database/Migrations/DatabaseMigrationRepository.php(129): Jenssegers\Mongodb\Schema\Builder->create(NULL, Object(Closure))
#6 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/database/Console/Migrations/InstallCommand.php(54): Illuminate\Database\Migrations\DatabaseMigrationRepository->createRepository()
#7 [internal function]: Illuminate\Database\Console\Migrations\InstallCommand->fire()
#8 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/container/Container.php(507): call_user_func_array(Array, Array)
#9 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/console/Command.php(169): Illuminate\Container\Container->call(Array)
#10 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#11 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#12 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/console/Command.php(185): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#13 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/database/Console/Migrations/MigrateCommand.php(106): Illuminate\Console\Command->call('migrate:install', Array)
#14 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/database/Console/Migrations/MigrateCommand.php(58): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#15 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#16 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/container/Container.php(507): call_user_func_array(Array, Array)
#17 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/console/Command.php(169): Illuminate\Container\Container->call(Array)
#18 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/illuminate/console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/symfony/console/Application.php(791): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/vhosts/collective-art.de/httpdocs/lumen/vendor/laravel/lumen-framework/src/Console/Kernel.php(69): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /var/www/vhosts/collective-art.de/httpdocs/lumen/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 {main}  

I'm using Lumen with the latest version.

Can anybody help me please?

Thanks!

@benargo
Copy link
Contributor

benargo commented Jun 15, 2016

The syntax for index has changed. Try this:

Schema::collection('mycollection', function ($collection)
{
            $collection->index('location', ['2dsphere']));
});

@javeedrahman
Copy link

javeedrahman commented Jan 31, 2017

How to change the datatype from string to int in mongodb,

Schema::collection('user, function ($collection)
{
// $collection->Int32('size')->change();
$collection->index('size', 'Int32');
});

@benargo can you please help me

@benargo
Copy link
Contributor

benargo commented Feb 15, 2017

@9787954511 MongoDB doesn't have restrictive column types, so there's no real need to create indices of this nature. I would advise using Eloquent's mutators if you need to validate data types here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants