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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="iacobson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/iacobson/120/2974_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  iacobson
                    <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>Indeed, queries will not look into the component’s internal state, which is also not their goal.</p>
<p>Depending on your game setup and what you try to achieve, there are multiple ways to achieve this. For example:</p>
<ol>
<li>If you really need the game ID to be stored in a component</li>
</ol>
<p>like <code>%Game{id: "game_id_1"}</code></p>
<p>This <strong>is not an ideal case</strong> if you have multiple parallel games and you need to query one of them. Still, you can achieve it by querying all <code>Game</code> components with their Entitites, then find the one you are looking for. For example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">{entity, game_component} = 
Ecspanse.Query.select({Ecspanse.Entity, Game})
|&gt; Ecspanse.Query.stream()
|&gt; Enum.to_list()
|&gt; Enum.filter(fn {entity, game_component} -&gt; game_component.id == "game_id_1" end)
</code></pre>
<p>Now you have your game entity, and game_component, if you need it.</p>
<ol start="3">
<li>If you do not need to store your game ID in a component</li>
</ol>
<p>You can optimize your code by spawning your game entity with a custom ID. You can still pass the Game component to it if you want.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Ecspanse.Command.spawn_entity!(
      {
        Ecspanse.Entity,
        id: "game_id_1",
        components: [{Game, id: "game_id_1"}]

# Then you can query the entity by its ID

{:ok, game_entity} = Ecspanse.Query.fetch_entity("game_id_1")

# Then if you need, you can fetch the game component for the game entity

{:ok, game_component} = Game.fetch(game_entity)
</code></pre>
<p>I hope this solves your current issue.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="341945" 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/ecspanse-an-entity-component-system-framework-for-elixir/57650/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-341945" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="341945"
                     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 #51"></div>
  </section>
</div>
    <div class="postbit" id="342035" data-post-id="342035">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Doh! That makes more sense. ID should be on the Entity, not the Component.</p>
<p>Much appreciated. <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="342035" 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/ecspanse-an-entity-component-system-framework-for-elixir/57650/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-342035" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="342035"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>