in reply to Re: Creating a perl delete statement with MongoDB
in thread Creating a perl delete statement with MongoDB

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 }

Replies are listed 'Best First'.
Re^3: Creating a perl delete statement with MongoDB
by Theodore (Hermit) on Jul 20, 2017 at 15:16 UTC
    for (ref $entry){ ## i think this will check for the type being input +by the use
    No, it will not.
Re^3: Creating a perl delete statement with MongoDB
by thanos1983 (Parson) on Jul 20, 2017 at 13:36 UTC

    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.

        Hello eOs

        What I meant to say is, we need you to replicate your scenario with executable code. But based on your update/answer This exercise is very hypothetical so there is no actual DB that I am querying from as of yet. how can we help you?

        From my point of view (maybe I am wrong), it looks like you have a theoretical idea on your mind and you are missing the deleting part. If this is the case why you do not create an actual sample of code as I said before (create DB, insert data, fetch data, delete data, fetch data to check the delete part(s)).

        If you have no real time data and indexes, columns, tables etc. how can we help?

        How can we replicate your problem? Should we create all of these data for you?

        I hope now my answer is more clear. Let me know in case that it is not clear again.

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