# Is it a good practice to use .equalTo("colName", undefined)?

**URL:** <https://community.parseplatform.org/t/is-it-a-good-practice-to-use-equalto-colname-undefined/3385>\
**Category:** Parse Server 📡\
**Tags:** query\
**Created:** [April 8, 2023, 9:05am UTC](https://community.parseplatform.org/t/is-it-a-good-practice-to-use-equalto-colname-undefined/3385 "2023-04-08T09:05:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreisu](https://community.parseplatform.org/user_avatar/community.parseplatform.org/andreisu/32/1414_2.png) [@andreisu](https://community.parseplatform.org/u/andreisu)\
**Post date:** [April 8, 2023, 9:05am UTC](https://community.parseplatform.org/t/is-it-a-good-practice-to-use-equalto-colname-undefined/3385/1 "2023-04-08T09:05:37Z")

</div>

I have a field that can have 3 states: true, false and undefined.

Each represents a different scenario.

1. Would using `query.equalTo("colName", undefined)` be more performant as it would allow utilizing an index vs `query.notContainedIn("colName", [true, false])` ? or will the value of undefined prevent MongoDB from utilizing the index, and therefore I should go with notContainedIn?

2. Also would `query.equalTo("colName", undefined)` be better than `query.doesNotExist("colName")` ?

Thank you

---

<div class="post-metadata">

**Author:** ![Moumouls](https://community.parseplatform.org/user_avatar/community.parseplatform.org/moumouls/32/332_2.png) [@Moumouls](https://community.parseplatform.org/u/Moumouls)\
**Post date:** [April 9, 2023, 8:19am UTC](https://community.parseplatform.org/t/is-it-a-good-practice-to-use-equalto-colname-undefined/3385/2 "2023-04-09T08:19:05Z")

</div>

Hi @andreisu if you read JS SDK docs you have the “exists” query constraint

[https://docs.parseplatform.org/js/guide/#query-constraints](https://docs.parseplatform.org/js/guide/#query-constraints)

In term of good practice about performance , it’s not really related to Parse but about common backends best practices:

- add indexes on fields used by many queries
- avoid negative queries

You have also a section about this in the docs [JavaScript Developers Guide | Parse](https://docs.parseplatform.org/js/guide/#performance)

But it’s not related to Parse, it’s some common best practices on backend/apis
