title: How to store a list in firebase firestore?
body: <p>I am trying to store a list with firebase firestore, but I always get a encoding error:</p>
  <p>UnhandledPromiseRejectionWarning: Error: Cannot encode value: a,b,c</p>
  <p>I have tried the following code snippets for <strong>node js</strong>:</p>
  <pre><code>const data = {
    a: &quot;hello world&quot;,
    b: [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]
  };
  
  const res = await db.collection('data').doc('one').set(data);
  </code></pre>
  <p>and</p>
  <pre><code>const data = {
    a: &quot;hello world&quot;,
    b: new Array([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;])
  };
  
  const res = await db.collection('data').doc('one').set(data);
  </code></pre>
  <p>and</p>
  <pre><code>const data = {
    a: &quot;hello world&quot;,
    b: []
  };
  
  const res = await db.collection('data').doc('one').set(data);
  </code></pre>
  <p>of which these all result in the same encoding error.</p>
  <p>I have also tried to store a list as the following the blog post here: <a href="https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html" rel="nofollow noreferrer">https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html</a></p>
  <pre><code>{
    0: &quot;a&quot;,
    1: &quot;b&quot;,
    2: &quot;c&quot;
  }
  </code></pre>
  <p>but this stored it as a object not a list and I need to store it as a list.</p>
  <p>I can create new documents with lists in the firebase console, but i cant do it programmatically. I am using node js.</p>
  <p>Thank you for aany help you can offer.</p>