<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="222840" data-post-id="222840">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/macrocreation" rel="nofollow">@macrocreation</a> , thanks a lot for the kind words!</p>
<p>You should not start more than a single <code>CubDB</code> process on the same database, because writers would conflict. In fact, in most cases, if you attempt to do so <code>CubDB</code> would detect it and give you an error.</p>
<p>You can safely call functions on a single <code>CubDB</code> process concurrently from other processes though. In particular, readers do not block each other and do not block writers (and read operations spawn separate reader processes, so multiple readers can run concurrently).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="222840" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/113">Post #112</a>
	                </div>
	            </div>
              <div id="likers-container-222840" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="222840"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #112"></div>
  </section>
</div>
    <div class="postbit" id="268661" data-post-id="268661">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tduccuong" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tduccuong
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>hey <a class="mention" href="/u/lucaong" rel="nofollow">@lucaong</a>,</p>
<p>thanks a lot for the very nice lib. I am using it for a project right now.</p>
<p>After reading <a href="https://hexdocs.pm/cubdb/howto.html#store-multiple-collections" rel="noopener nofollow ugc">this how-to</a>, I wonder if I can efficiently empty a collection, without having to find out all the existing keys first?</p>
<p>Say I have <code>devices</code> collection, which potentially contains millions of entries. I am looking for something like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">CubDB.delete_range(cubdb, min_key: {:devices, 1}, max_key: {:devices, 1000000})
</code></pre>
<p>What do you think?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="268661" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/114">Post #113</a>
	                </div>
	            </div>
              <div id="likers-container-268661" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="268661"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #113"></div>
  </section>
</div>
    <div class="postbit" id="268666" data-post-id="268666">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/tduccuong" rel="nofollow">@tduccuong</a> ,<br>
Thanks for the kind words <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Having to efficiently remove a whole big collection would be a possibly good reason to put the collection in its own <code>CubDB</code> database: it is then possible to use <code>CubDB.clear</code> to remove everything in a very efficient way (like a truncate table in SQL).</p>
<p>Otherwise, one can gather the keys to delete with a <code>CubDB.select</code>, then call <code>CubDB.delete_multi</code> passing all the keys (possibly doing this in batches if the collection is really big). This still removes each individual entry though, much like a delete in SQL.</p>
<p>Each <code>CubDB</code> database is a b-tree, much like each individual table or index in Postgres. The trade-off is that transactions only work on a single database, so you should decide whether to use a separate database per collection or a single one based on whether you need efficient “truncate” semantics, versus whether you need atomic transactions involving this collection together with other ones.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="268666" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/115">Post #114</a>
	                </div>
	            </div>
              <div id="likers-container-268666" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="268666"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #114"></div>
  </section>
</div>
    <div class="postbit" id="268667" data-post-id="268667">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry <a class="mention" href="/u/macrocreation" rel="nofollow">@macrocreation</a> , I missed your message. EDIT: I did not miss it, apparently I replied and I did not see…</p>
<p>For the sake of those who read this thread, the answer is that, as specified in the docs, at most a single <code>CubDB</code> process should be started at any time on a specific data directory. It is then possible to call the <code>CubDB</code> functions from several processes concurrently, but there should be only one <code>CubDB</code> process managing each specific data folder.</p>
<p>In fact, <code>start_link</code> will fail when called twice on the same data directory within the same VM (ideally it should fail even if called twice on the same data directory across VMs, but it’s a lot harder to do in a cross-platform way as far as I know).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="268667" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/116">Post #115</a>
	                </div>
	            </div>
              <div id="likers-container-268667" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="268667"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #115"></div>
  </section>
</div>
    <div class="postbit" id="268853" data-post-id="268853">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tduccuong" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tduccuong
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks a lot for your quick reply <a class="mention" href="/u/lucaong" rel="nofollow">@lucaong</a>, given the flexibility in managing DB file per process, I think it makes sense to have each DB file as a collection.</p>
<p>Btw, I wanted to ask you if indexing value is in your feature roadmap? Something like, finding a range of devices based on <code>user_id</code>. I can simulate it now at application level, given the existing CubDB primitives. E.g., having another collection with ID as <code>{user_id, device_id}</code>, then CRUD that collection upon CRUD <code>devices</code> collection. But would be nice if that will be done at DB level.</p>
<p>Thanks again for your advice!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="268853" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/117">Post #116</a>
	                </div>
	            </div>
              <div id="likers-container-268853" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="268853"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #116"></div>
  </section>
</div>
    <div class="postbit" id="269321" data-post-id="269321">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/tduccuong" rel="nofollow">@tduccuong</a> ,<br>
Yes, as you said, the recommended way to create a secondary index is to create a second collection in the same database, keyed by the index field, and using “primary keys” as values.</p>
<p>The main collection and its index can be updated together in atomic transactions (I am typing this from a phone, so I will definitely make some mistakes, but hopefully it gives you the gist of it):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># This implements:
#  - a collection of users by ID, with keys like {:users, id} and %User{} structs as values
#  - a collection, implementing the secondary index, of users by name,
#    with keys like {:users_name_idx, name} and lists of user IDs as values

def insert_user(db, user) do
  CubDB.transaction(db, fn tx -&gt;
    tx = CubDB.Tx.put(tx, {:users, user.id}, user)
    ids = CubDB.Tx.get(tx, {:users_name_idx, user.name}, [])
    tx = CubDB.Tx.put(tx, {:users_name_idx, user.name}, [user.id | ids])
    {:commit, tx, user}
  end)
end

def get_user_by_id(db, id) do
  CubDB.get(db, {:users, id})
end

def get_users_by_name(db, name) do
  CubDB.with_snapshot(db, fn snap -&gt;
    ids = CubDB.Snapshot.get(snap, {:users_name_idx, name})
    keys = Enum.map(ids, fn id -&gt; {:users, id} end)
    CubDB.Snapshot.get_multi(snap, keys) |&gt; Map.values()
  end)
end
</code></pre>
<p>At the moment there is no plan to implement secondary indexes as a first class concept in <code>CubDB</code>. That’s because <code>CubDB</code> strives to be first of all a simple, minimal, and versatile building block for higher level products.</p>
<p>That said, I would be lying if I said that I am not hoping to find the time to build a higher level library on top of it, providing facilities like “tables” and indices <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> but if you really depend on that level of abstraction, it’s probably better to use an SQL solution like SQLite.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="269321" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/118">Post #117</a>
	                </div>
	            </div>
              <div id="likers-container-269321" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="269321"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #117"></div>
  </section>
</div>
    <div class="postbit" id="269327" data-post-id="269327">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>By the way, for those interested in <code>CubDB</code>, the thread in <a class="hashtag-cooked" href="/c/your-libraries-os-mentoring/libraries/43" data-type="category" data-slug="libraries" data-id="43" data-style-type="square" data-ref="your-libraries-os-mentoring:libraries" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>Your Libraries &amp; Projects &gt; Libraries</span></a> is the most up to date, and where announcements happen:</p>
<aside class="quote quote-modified" data-post="1" data-topic="48631">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/48/21794_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-database/48631" rel="nofollow">CubDB - A pure-Elixir embedded database</a> <a class="badge-category__wrapper " href="/c/news/announcing/159" rel="nofollow"><span data-category-id="159" style="--category-badge-color: #d2407f; --category-badge-text-color: #FFFFFF; --parent-category-badge-color: #d2407f;" data-parent-category-id="158" data-drop-close="true" class="badge-category --style-square --has-parent"><span class="badge-category__name">Announcing</span></span></a>
    </div>
  </div>
  <blockquote>
    <a href="https://github.com/lucaong/cubdb" rel="noopener nofollow ugc">CubDB</a> is an embedded database written in pure Elixir, designed for robustness and minimal use of resources. It strives to be as developer-friendly as possible. 
Some of you, especially in the Nerves community, already know and use CubDB since a while, and might have read <a href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397" rel="nofollow">the original thread about CubDB on the Nerves Forum</a>. 
Version v2.0.0 is now <a href="https://hexdocs.pm/cubdb/CubDB.html" rel="noopener nofollow ugc">published on Hex</a>, with big improvements and exciting new features, so I thought it is a good time for a proper library post here. 
Since this is a long-…
  </blockquote>
</aside>

<p>There is also a <a class="hashtag-cooked" href="/tag/cubdb/3283" data-type="tag" data-slug="cubdb" data-id="3283" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>cubdb</span></a> tag that can be used for questions or topics related to it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="269327" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/119">Post #118</a>
	                </div>
	            </div>
              <div id="likers-container-269327" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="269327"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #118"></div>
  </section>
</div>
    <div class="postbit" id="270687" data-post-id="270687">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kwando" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kwando/120/4092_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kwando
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ii can’t get transactions to work´, whatever they write is not ending up in the database <img src="https://forum.elixirforum.com/images/emoji/apple/cry.png?v=15" title=":cry:" class="emoji" alt=":cry:" loading="lazy" width="20" height="20"> Cant see what I’m doing wrong <img src="https://forum.elixirforum.com/images/emoji/apple/confused.png?v=15" title=":confused:" class="emoji" alt=":confused:" loading="lazy" width="20" height="20"></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  test "transaction" do
    {:ok, cub} = CubDB.start_link("data/test")

    CubDB.transaction(cub, fn tx -&gt;
      CubDB.Tx.put(tx, :foo, :bar)
      {:commit, tx, :ok}
    end)

    assert CubDB.get(cub, :foo) == :bar    # blows up with

    CubDB.stop(cub)
  end
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir"> Assertion with == failed
     code:  assert CubDB.get(cub, :foo) == :bar
     left:  nil
     right: :bar
     stacktrace
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">CubDB: v.2.0.2
❯ mix hex.info
Hex:    2.0.0
Elixir: 1.14.2
OTP:    25.0.1

Built with: Elixir 1.14.1 and OTP 23.3
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="270687" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/120">Post #119</a>
	                </div>
	            </div>
              <div id="likers-container-270687" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="270687"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #119"></div>
  </section>
</div>
    <div class="postbit" id="270688" data-post-id="270688">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="outlog" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  outlog
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>Note that write functions in <a href="https://hexdocs.pm/cubdb/CubDB.Tx.html" rel="noopener nofollow ugc"><code>CubDB.Tx</code></a> have a functional API: they return a modified transaction rather than mutating it in place.<br>
<a href="https://hexdocs.pm/cubdb/CubDB.html#transaction/2" class="inline-onebox" rel="noopener nofollow ugc">CubDB — cubdb v2.0.2</a></p>
</blockquote>
<p>You need to commit the modified transaction, not the original (empty) one..</p>
<p>eg: add <code>tx =</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  CubDB.transaction(cub, fn tx -&gt;
    tx = CubDB.Tx.put(tx, :foo, :bar)
    {:commit, tx, :ok}
  end)
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="270688" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/121">Post #120</a>
	                </div>
	            </div>
              <div id="likers-container-270688" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="270688"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #120"></div>
  </section>
</div>
    <div class="postbit" id="270694" data-post-id="270694">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lucaong" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/120/21794_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lucaong
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, exactly as <a class="mention" href="/u/outlog" rel="nofollow">@outlog</a> says. Basically, think about transactions similarly to how you use Elixir maps or other immutable data structures: you apply operations on them and get a mutated copy, as opposed to imperatively mutating them in place. That’s the same with CubDB transactions.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="270694" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/cubdb-a-pure-elixir-embedded-key-value-database/23397/122">Post #121</a>
	                </div>
	            </div>
              <div id="likers-container-270694" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="270694"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #121"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/23397/load_more?page=13">Load more posts (4 remaining)</a>
</div></template></turbo-stream>