I saw you call insert on a DB object in Synopsis, under "normal usage".
use MongoDBx::Class; # create a new instance of the module and load a model
schema my $dbx = MongoDBx::Class->new(namespace => 'MyApp::Model::DB'); #
if MongoDBx::Class can't find your model schema (possibly because # it
exists in some different location), you can do this: my $dbx = MongoDBx::
Class->new(namespace => 'MyApp::Model::DB', search_dirs => [
'/path/to/model/dir']); # connect to a MongoDB server my $conn = $dbx->
connect(host => 'localhost', port => 27017); # be safe by default $conn->
safe(1); # we could've also just passed "safe => 1" to $dbx->connect() above #
get a MongoDB database my $db = $conn->get_database('people'); # insert a
person my $person = $db->insert({ name => 'Some Guy', birth_date =>
'1984-06-12', _class => 'Person' }); print "Created person ".$person->name."
(".$person->id.")\n"; $person->update({ name => 'Some Smart Guy' }); $person
->delete;
I don't see get_collection anywhere in that.
On Fri, Jan 31, 2014 at 11:32 AM, Ido Perelmutter via RT <
bug-MongoDBx-Class@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=92616 >
>
> On Fri Jan 31 11:18:28 2014, jacoby.david@gmail.com wrote:
> > POD says the following should work for inserting into MongoDB
> >
> > $movie = { title => 'Blade Runner' , rating => 'R' , releaseYear =>
> > '1982' , hasCreditCookie => 1 } ;
> > $db->insert($movie) ;
> >
> > When I try it, I get
> >
> > AUTOLOADed collection method names are deprecated and will be removed in
> a
> > future release. Use $db->get_collection( 'insert' ) instead. at
> > /home/jacoby/bin/test_mongodbx.pl line 28.
> >
> > I can't even tell what the new syntax should be, because pulling code
> from
> > the CPAN tutorial page means I don't know what I'm doing yet. The POD
> > should show a line of code that doesn't get an error.
> >
>
> Your error seems to be that you're calling the insert() method on a
> database object instead of a collection object. First get the collection
> into which you want to insert:
>
> my $coll = $db->get_collection('some_collection');
>
> And then call insert:
>
> $coll->insert($doc);
>
> Where in the documentation did you see me calling insert() on a database
> object?
>
--
David Jacoby jacoby.david@gmail.com