# Can't the database query results in the cloud code be modified?

**URL:** <https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899>\
**Category:** Cloud Code\
**Created:** [March 28, 2025, 10:58am UTC](https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899 "2025-03-28T10:58:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toodoo](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@toodoo](https://community.parseplatform.org/u/toodoo)\
**Post date:** [March 28, 2025, 10:58am UTC](https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899/1 "2025-03-28T10:58:21Z")

</div>

I encountered a problem. I queried a batch of data from the database. It was normal to return the data to the client unchanged. The client received a Map of ParseObject, and I could convert it into a ParseObject. However, once I modified the data, the data received by the client became abnormal.

Normal data:

```auto
List (20 items)
[0] =
Map (12 items)
0 =
"images" -> List (1 item)
1 =
"location" -> Map (3 items)
2 =
"author" -> Map (11 items)
3 =
"content" -> "xxxxxxx"
4 =
"comments" -> 0
5 =
"likes" -> 1
6 =
"createdAt" -> "2025-03-25T14:41:49.282Z"
7 =
"updatedAt" -> "2025-03-26T23:58:06.532Z"
8 =
"ACL" -> Map (2 items)
9 =
"objectId" -> "FhO5vFdmFh"
10 =
"__type" -> "Object"
11 =
"className" -> "Post"
[1] =
Map (11 items)
[2] =
Map (12 items)
[3] =
Map (12 items)
[4] =
Map (12 items)
[5] =
Map (12 items)
[6] =
Map (12 items)

```

Abnormal data:

```auto
List (20 items)
[0] =
Map (3 items)
0 =
"__type" -> "Pointer"
1 =
"className" -> "Post"
2 =
"objectId" -> "FhO5vFdmFh"
[1] =
Map (3 items)
[2] =
Map (3 items)
[3] =
Map (3 items)
[4] =
Map (3 items)
[5] =
Map (3 items)
[6] =
Map (3 items)
[7] =
Map (3 items)
[8] =
Map (3 items)
[9] =
Map (3 items)
[10] =
Map (3 items)
[11] =
Map (3 items)
[12] =
Map (3 items)
[13] =
Map (3 items)
[14] =
Map (3 items)
[15] =
Map (3 items)
[16] =
Map (3 items)
[17] =
Map (3 items)
[18] =
Map (3 items)
[19] =
Map (3 items)

```

This is my cloudcode:

```auto
const results = await query.find({ sessionToken: sessionToken });
for (var post of results) {
       //post.set('aaa', 'aaaa'); //This line of code causes the problem.
}
return results;

```

---

<div class="post-metadata">

**Author:** ![dplewis](https://community.parseplatform.org/user_avatar/community.parseplatform.org/dplewis/32/233_2.png) [@dplewis](https://community.parseplatform.org/u/dplewis)\
**Post date:** [March 28, 2025, 3:28pm UTC](https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899/2 "2025-03-28T15:28:39Z")

</div>

The way cloud code works is when you return the results it gets encoded first and then decoded on the client side. If we add an options to either remove the encoding / decoding or both it should fix your issue. You can use the workaround posted here [Return Plain Objects from Cloud Code - #7 by BobyIlea](https://community.parseplatform.org/t/return-plain-objects-from-cloud-code/4860/7)

Can you write a failing test on the JS SDK so we can replicate your issue?

> <https://github.com/parse-community/Parse-SDK-JS/blob/alpha/CONTRIBUTING.md>

---

<div class="post-metadata">

**Author:** ![toodoo](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@toodoo](https://community.parseplatform.org/u/toodoo)\
**Post date:** [March 28, 2025, 4:55pm UTC](https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899/3 "2025-03-28T16:55:18Z")

</div>

Thank you for the reply from dplewis. The solution I’m using now is also to call `toJSON` in the cloud code, and then convert it using `ParseObject('Post').fromJson` on the client side. I’m really sorry, but I’m using the Flutter SDK.

---

<div class="post-metadata">

**Author:** ![BobyIlea](https://community.parseplatform.org/user_avatar/community.parseplatform.org/bobyilea/32/1966_2.png) [@BobyIlea](https://community.parseplatform.org/u/BobyIlea)\
**Post date:** [March 28, 2025, 10:52pm UTC](https://community.parseplatform.org/t/cant-the-database-query-results-in-the-cloud-code-be-modified/4899/4 "2025-03-28T22:52:15Z")

</div>

I think it’s because of this:

> <https://github.com/parse-community/Parse-SDK-JS/blob/6fceea491c4542ee064600cbaea80f3f1a05ef61/src/encode.ts#L25C1-L31C32>

If you set a value on an object without saving it, it becomes dirty. And it seems that the encoder checks if the object is dirty and if it is, it converts it to pointer. Not really sure what’s the reason behind this, but it seems intentional.
