firebase / firebase/firebase-ios-sdk

Async getData() returns the value of parent node instead of the child node.

Open
#12,965 13 comments 17 reactions 0 assignees View on GitHub
api: database
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 14h
Merged PRs (30d)
72

Description

### Description

Hello!

When I call the async `getData()` method, it returns the snapshot of the parent, not the actual child.

### Reproducing the issue

Create `User` node and two nodes inside of it: `id`, `name`.

- User
-- id : testId
-- name: testName

Call: `let userId = try! await Database.database().reference().child("User").child("id").getData().value`

It returns 2 key-value pairs **id="testId"**, **name="testName"**. But not the `id` only.

### Firebase SDK Version

10.17.0

### Xcode Version

15.1

### Installation Method

Swift Package Manager

### Firebase Product(s)

Database

### Targeted Platforms

iOS

### Relevant Log Output

```shell
No logs.
```

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.