Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.62k stars 600 forks source link

Cannot access property from database response #1787

Open Stophface opened 6 months ago

Stophface commented 6 months ago

I cannot access a property from my database in JS, eventhough it is clearly there.

const foo = {"__changes": null, "_isEditing": false, "_preparedState": null, "_raw": {"_changed": "", "_status": "created", "continent_id": "8", "country_id": "193", "id": "197126", "latitude": 52.51993, "longitude": 13.43585, "name": "St. Pius-Kirche", "osm_type_id": "21", "quest_type_id": "3", "visited_date": ""}, "_subscribers": [], "collection": {"_cache": {"_debugCollection": [Circular], "map": [Map], "recordInsantiator": [Function anonymous], "tableName": "europe_quest"}, "_subscribers": [], "changes": {"closed": false, "currentObservers": null, "hasError": false, "isStopped": false, "observers": [Array], "thrownError": null}, "database": {"_isBeingReset": false, "_isBroken": false, "_pendingNotificationBatches": 0, "_pendingNotificationChanges": [Array], "_resetCount": 0, "_subscribers": [Array], "_workQueue": [WorkQueue], "adapter": [DatabaseAdapterCompat], "collections": [CollectionMap], "schema": [Object]}, "modelClass": [Function EuropeQuest]}}

I want to access "osm_type_id": "21" which I try like this foo['osmTypeId']. This returns undefined. I also tried it like this foo['osm_type_id'] which also returns undefined. Strange enough, I can access any other property like foo['questTypeId'].

It works when I do this

foo._raw['osm_type_id']

Why is that?