# Can I place pointer (as value for some key) inside field with object type?

**URL:** <https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964>\
**Category:** JavaScript SDK\
**Created:** [October 23, 2020, 8:44pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964 "2020-10-23T20:44:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://community.parseplatform.org/u/Andy)\
**Post date:** [October 23, 2020, 8:44pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/1 "2020-10-23T20:44:26Z")

</div>

I need a field, that contains one pointer. Pointer type is not suitable cuz pointer may be for different entities, so I thought about Array or Object. For me it will be no matter which except theoretical performance when search by this field.

As to Array - it’s simple, I can see in a dashboard pointer as object with type pointer and className.  
But in case with Object field - there is only key `objectId`:  
`{ "pointerKey": { "objectId": "gmMepz8C06" } }`

So pointers only for Pointer, Array or relations?

If for search query with Object I could use  
`equalTo('fieldName.pointerKey', pointer)`  
then what can I use with Array - `equalTo('fieldName', [pointer])` ?  
May be `'fieldName[0]'`?

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 23, 2020, 9:05pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/2 "2020-10-23T21:05:32Z")

</div>

I’d go with an object column. You can have something like this stored in each of your rows:

```json
{ "className": "SomeClass", "objectId": "someobjectid" }

```

, then you can find using:

```auto
query.equalTo('fieldName.className','SomeClass'')
query.equalTo('fieldName. objectId','someobjectid'')

```

---

<div class="post-metadata">

**Author:** ![Andy](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://community.parseplatform.org/u/Andy)\
**Post date:** [October 23, 2020, 9:18pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/3 "2020-10-23T21:18:31Z")

</div>

Has it any advantages before using Array field?

Or before

```auto
query.equalTo('fieldName', { "className": "SomeClass", "objectId": "someobjectid" })

```

Is that matter of performance?

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 23, 2020, 10:28pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/4 "2020-10-23T22:28:00Z")

</div>

I am not sure regarding the performance but I believe both queries will have about the same performance. I suggested object (and not array) because I understood you needed to store only one pointer per row. You can use array as well and these queries should also work.

---

<div class="post-metadata">

**Author:** ![Andy](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://community.parseplatform.org/u/Andy)\
**Post date:** [October 23, 2020, 10:44pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/5 "2020-10-23T22:44:18Z")

</div>

In mongo [we can do](https://docs.mongodb.com/manual/tutorial/query-arrays/#query-an-array-for-an-element)

> The following example queries for all documents where `tags` is an array that contains the string `"red"` as one of its elements:
> 
> `const cursor = db.collection('inventory').find({ tags: 'red' });`

May be with array field in parse query I can use something like this  
`equalTo('fieldName', pointer)`  
instead of `equalTo('fieldName', [pointer])` or `equalTo('fieldName.0', pointer)`

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 23, 2020, 10:55pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/6 "2020-10-23T22:55:58Z")

</div>

Yes. You can do

```auto
equalTo('fieldName', pointer)

```

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 23, 2020, 10:56pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/7 "2020-10-23T22:56:29Z")

</div>

Take a look at this doc: [https://docs.parseplatform.org/js/guide/#using-an-array](https://docs.parseplatform.org/js/guide/#using-an-array)

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [October 23, 2020, 10:57pm UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/8 "2020-10-23T22:57:15Z")

</div>

You will probably not be able to use the include because you will have pointers to different classes, but the other features should work for your case.

---

<div class="post-metadata">

**Author:** ![renatomuniz15](https://community.parseplatform.org/user_avatar/community.parseplatform.org/renatomuniz15/32/672_2.png) [@renatomuniz15](https://community.parseplatform.org/u/renatomuniz15)\
**Post date:** [June 1, 2021, 1:56am UTC](https://community.parseplatform.org/t/can-i-place-pointer-as-value-for-some-key-inside-field-with-object-type/964/9 "2021-06-01T01:56:33Z")

</div>

Hi guys, does anyone know how to do this same filter being that in Java (android) ?

I open this quest,  
[https://community.parseplatform.org/t/filter-in-java-android-with-parsequery-field-type-pointer/1719](https://community.parseplatform.org/t/filter-in-java-android-with-parsequery-field-type-pointer/1719)  
tks
