firebase / firebase/firebase-tools

How to use DocumentReference fields in functions:shell

Open
#753 18 comments 5 reactions 1 assignee Claimed by @taeold View on GitHub
emulators: functions polish type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### Version info

3.18.4

### Platform Information

macOS 10.12.6

### Steps to reproduce

I'm trying to use `firebase functions:shell` to test some functions locally, e.g.:
```ts
functions.firestore.document('inquiries/{inquiryId}')
.onCreate(async snapshot => {
const data = snapshot.data();
const refData = await data.docWithRef.get();
// Do some operations on refData
});
```

### Expected behavior

I'm not sure how to test with an object that it's supposed to have a document reference.
Say I have a simple object with a ref:
```js
{
timestamp: 123,
docWithRef: DocumentReference
}
```
How can I run that in the repl that the shell created? Is that actually possible?

And I'm a little confused. When the `onCreate()` trigger that I use will invoke the callback with the data, will the snapshot actually contain `docWithRef` as a proper `DocumentReference`
or will it be just a path?

### Actual behavior

Cannot seem to find a way to mock a doc ref.

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.