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.