title: How to set collation rules with TypeORM for MongoDB?
body: <p>I am using <code>mongoDB</code> with <code>TypeORM</code> to create queries, like this:</p>
  <pre><code>      const repository = queryRunner.manager.getRepository(&quot;...&quot;);
  
        const conditions = { take: ..., skip: ..., where: {...}, order: ... };
  
        const [entities, count] = await repository.findAndCount(conditions);
  
  
        return {
          data: entities as T[],
          count: count
        };
  </code></pre>
  <p>This works without any issue. My current task is to implement <a href="https://docs.mongodb.com/manual/reference/collation/#behavior" rel="nofollow noreferrer">localized collation behaviour</a>. Currently, by default, special characters are not ordered by hungarian rules (A-&gt;Á-&gt;B-&gt;C etc.) and there is an upper-lower character order which I do not want to have (a-&gt;A-&gt;b-&gt;B order).</p>
  <p>How can I do that? Here is what I have tried so far:</p>
  <ol>
  <li>tried setting <code>ColumnOptions</code> in <a href="https://github.com/typeorm/typeorm/blob/master/docs/entities.md#column-options" rel="nofollow noreferrer">entities</a>:</li>
  </ol>
  <p>In my base entities, setting <code>{name: ..., collation: 'hu', charset: 'utf-8'}</code> did not have any effect.</p>
  <ol start="2">
  <li>Tried setting collation as a <code>FindCondition</code>:</li>
  </ol>
  <pre><code>      const repository = queryRunner.manager.getRepository(&quot;...&quot;);
  
        const conditions = { take: ..., skip: ..., where: {...}, order: ... };
  
        conditions['collation'] = {
          locale: 'hu',
          caseLevel: false,
          caseFirst: false,
        }
  
        const [entities, count] = await repository.findAndCount(conditions);
  
  
        return {
          data: entities as T[],
          count: count
        };
  </code></pre>
  <p>But this has no effect on the query result whatsoever. At this point I am confused, as far as I could tell, both approach should work :\</p>