Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: MongoDB removing document

by NetWallah (Canon)
on Oct 26, 2015 at 17:19 UTC ( [id://1146005]=note: print w/replies, xml ) Need Help??


in reply to MongoDB removing document

The actual ID you are trying to delete has the VALUE 'something_unique' , and is of the TYPE/CLASS 'MongoDB::OID'.

So - without knowing the MongoDB API, your error is passing in the TYPE, rather than the VALUE.

I'd suggest:

$doc->delete_one( {'_id'=>$doc->{_id} } ); # If that fails, try: $doc->delete_one( {'_id'=>$doc->{_id}{value} } );
There are potentially other issues, but this should help step you past the current one.

good luck.

        The best defense against logic is ignorance.

Replies are listed 'Best First'.
Re^2: MongoDB removing document
by GertMT (Hermit) on Oct 26, 2015 at 18:07 UTC
    Thank you for your reply

    Unfortunately I keep getting the message:

    Can't call method "delete_one" on unblessed reference at line...

    I'll investigate further.

      I know absolutely nothing about MongoDB, but I can tell you that you're trying to call a method on something that doesn't have any (a plain hash reference).

      In the MongoDB documentation's SYNOPSYS, it shows that to delete a document, you call the method against the collection ($coll) object like this: $coll->delete_one({ name => 'value' });

      For completeness, here's the expanded documentation specifically for the delete_one() method.

      When in doubt, RTFM ;)

        Thanks, after studying the documents (that are really well done!) I indeed do have a problem executing the proper commands while iterating the MongoDB::Cursor. There are not too many examples of that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1146005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-19 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found