in reply to Creating a perl delete statement with MongoDB

Hello eOs,

Welcome to the monastery. Please read How do I post a question effectively? and also as you said MongoDB::Tutorial/Updating Documents find the syntax $users->delete_many({"name" => "Joe"});.

We can not help you without seeing the minimum amount of code and effort.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: Creating a perl delete statement with MongoDB
by e0s (Novice) on Jul 20, 2017 at 13:28 UTC
    definitely forgot to post my code. sorry.

    at this point i've tried creating a subroutine that is attempting to do this:

    sub delete_thefruits my $collection; my $criteria;
    for (ref $entry){ ## i think this will check for the type being input +by the user when ('fruitdb::name') { $collection = $FRUIT_NAMES; $criteria->(name) = $entry->{data}{name};
    If i create a similar function to the above, another one which only deals with the fruitIDs table, would perl understand to differentiate between the two?? or would I need to illustrate that programmatically?
    $collection-> remove(criteria); ## this will hopefully eventually remo +ve one entry whether it's fruit name or fruitID }
      for (ref $entry){ ## i think this will check for the type being input +by the use
      No, it will not.

      Hello again eOs,

      What I would do in your case is try to create a minimal working example for everyone here to play. For example, create db, insert data, then retrieve data, delete and retrieve again.

      It is really difficult to guess what is returned and what it should be deleted (at least to me). You have the code in you node and you can execute it at any time but we do not have it, so guessing is not the best way to proceed.

      Help us to help you, BR.

      Seeking for Perl wisdom...on the process of learning...not there...yet!
        Thanks for the reply but I am not sure what you mean. For example inserting any numeric character would pull from the fruit_ids table and entering 'banana' would pull a result from the fruit_names table. This exercise is very hypothetical so there is no actual DB that I am querying from as of yet. I am just trying to create a blueprint of what the code would possibly look like. Would it be possible to continue along just taking some of this for face value? upon deletion, I am only attempting to return a result which indicates the fruit name or fruit ID was removed from the DB.