Loading ...
Sorry, an error occurred while loading the content.

how to print array after filtering records using find function

Expand Messages
  • irshadansari_06
    Hi, Can you let me know how to print array after filtering records using find function because find function returns indexes and we cant pass index to
    Message 1 of 2 , Aug 4 4:53 AM
    • 0 Attachment
      Hi,

      Can you let me know how to print array after filtering records using find function because find function returns indexes and we cant pass index to gridprinter function.

      So, can you please let me know that how to print records from the index get from the find function.

      Thanks,
      Irshad
    • tacoman_cool
      Hi Irshad, There are three main methods that help you work with your data in TaffyDB. Find, Get, and forEach. First and Last are also version of get that only
      Message 2 of 2 , Aug 4 8:46 AM
      • 0 Attachment
        Hi Irshad,

        There are three main methods that help you work with your data in TaffyDB. Find, Get, and forEach. First and Last are also version of get that only return the first or last record.

        Find returns the indexes that match your query. Calling .find() will return an array with every index from your collection. Calling find ({status:"active"}) will return an array with the index for every active record.

        Get returns the objects (or records) themselves. Just like find you can call .get() to get all records or .get({status:"active"}) to get the active records. You can then loop over that array collection like normal. There are rare cases that you'd want to use them together so passing indexes into get is total valid. You can cal get(1), get([0,2,4]) or even get(collection.find({status:"active")));

        forEach will take either a query object such as {status:"active"} or an array of indexes such as [0,2,4] and will loop over each record and call a function you define, passing the record as the first argument and the index as the second.

        forEach is what I used most when building web apps. An exmaple call would be something like .forEach(function (r,i) {alert(r.name + " is active and has an index of " + i},{status:"active"});

        Hope that helps,

        Ian

        --- In taffydb@yahoogroups.com, "irshadansari_06" <irshadahmed.ansari@...> wrote:
        >
        > Hi,
        >
        > Can you let me know how to print array after filtering records using find function because find function returns indexes and we cant pass index to gridprinter function.
        >
        > So, can you please let me know that how to print records from the index get from the find function.
        >
        > Thanks,
        > Irshad
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.