title: How to get atoms with certain prefix from an atom family
body: <p>I am new to recoil and am trying to understand how to</p>
  <ol>
  <li><p>retrieve atoms with certain key prefixes (e.g. &quot;customerId-xyz&quot;) from an atom family – would I have to filter the productKeys every time by customerId in the component? That does not sound right.</p>
  </li>
  <li><p>retrieve all products for for a customer that have a certain value (e.g. size = S) from an atom family.</p>
  </li>
  </ol>
  <p>See the simplified setup below...</p>
  <p>Thanks for your time!</p>
  <pre><code>
  export const productsAtom = atomFamily&lt;Partial&lt;Product&gt;, string&gt;({
      key: &quot;productsAtom&quot;,
      default: {
          name: &quot;&quot;,
          size: &quot;&quot;,
      },
  });
  
  
  export const productKeysAtom = atom&lt;string[]&gt;({
      key: &quot;productKeysAtom&quot;,
      default: [],
  });
  
  export const productsSelector = selectorFamily&lt;
      Partial&lt;Product&gt;,
      string
  &gt;({
      key: &quot;productsSelector&quot;,
      get:
          (productKey) =&gt;
          ({ get }) =&gt; {
              return get(productsAtom(productKey));
          },
      set:
          (productKey) =&gt;
          ({ set, get, reset }, updatedData) =&gt; {
              if (updatedData instanceof DefaultValue) {
                  reset(productsAtom(productKey));
  
                  set(productKeysAtom, (existingKeys) =&gt;
                      existingKeys.filter((key) =&gt; key !== productKey),
                  );
  
                  return;
              }
  
              set(productsAtom(productKey), (product) =&gt; {
                  return {
                      ...product,
                      ...updatedData,
                  };
              });
  
              const productKeys = get(productKeysAtom);
  
              if (!productKeys.includes(productKey)) {
                  set(productKeysAtom, (keys) =&gt; [...keys, productKey]);
              }
          },
  });
  </code></pre>