firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 929 forks source link

How to use DocumentReference fields in functions:shell #753

Open rolandjitsu opened 6 years ago

rolandjitsu commented 6 years ago

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.:

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:

{
  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.

laurenzlong commented 6 years ago

@rolandjitsu We don't yet support Firestore document reference or geo points in the functions shell yet. Sorry about that. I'll take this as a feature request.

rolandjitsu commented 6 years ago

@laurenzlong ok, no worries. I guess I'll just test the fn after I deploy it. Are there any plans to support that in the future?

laurenzlong commented 6 years ago

Yes, we do plan to support it in the future. No timelines at the moment.

lucafaggianelli commented 5 years ago

I got this error in the emulator The emulator does not yet support Firestore document reference values or geo points so it appears that there's no update on this feature...any news?

NoFr1ends commented 5 years ago

Any updates on this?

henriquezago commented 5 years ago

Apparently no updates...

bradleymackey commented 4 years ago

Bump. With all the emulator news from the Firebase Summit '19 I'm surprised this is still outstanding.

samtstern commented 4 years ago

Thanks for the bump! We will be going through the bug backlog next week to try and smooth out all of the known emulator issues when possible.

Things got a little crazy leading up to the summit (as you can imagine) but now we should be able to get through a lot of these. I'll personally be looking into this one.

On Thu, Oct 3, 2019, 8:14 PM Bradley Mackey notifications@github.com wrote:

Bump. With all the emulator news from the Firebase Summit '19 I'm surprised this is still outstanding.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/753?email_source=notifications&email_token=ACATB2UDJKW7EAF7HRTTKU3QMYK65A5CNFSM4E4JI3D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAIXNDI#issuecomment-538015373, or mute the thread https://github.com/notifications/unsubscribe-auth/ACATB2WTHVLSOSXSQTLO3KTQMYK65ANCNFSM4E4JI3DQ .

bradleymackey commented 4 years ago

Possibly related: https://github.com/firebase/firebase-functions-test/issues/47

samtstern commented 4 years ago

For those waiting on progress here I have some questions:

  1. Do you need support for document references in the functions:shell? If so can you suggest the syntax you'd like to use for creating doc refs at the command line?
  2. If you dont need doc ref support in the shell what sort of support do you need in the emulator?
Dinduks commented 4 years ago

Hi. It's been two years since this issue was opened. Any news please?

samtstern commented 4 years ago

We improved support for this in the emulator. There is no update to firebase:shell so far.

ghost commented 3 years ago

When I create a document in Emulator which has got fields of type "Reference", after the creation of the document, all its fields (documentReference ones) are converted to an empty string. This is very frustrating because literally I cannot test my functions before deploying them. It's very strange because if I edit the field of that same document individually after creation, then I can change the field type to "Reference" with proper value successfully!

samtstern commented 3 years ago

@CambridgeAlgoRD that sounds like a new bug and not the central issue here (which is about shell support) so do you mind opening a new issue with all the steps to reproduce?

HasarAli commented 2 years ago

I was hoping to get a DocRef by adding a reference manually through the emulator UI, but that did not work for me either.

yuchenshi commented 2 years ago

@HasarAli Would you mind opening a new issue to clarify what you've tried, what is the expected behavior and the actual behavior? That will help us look more into this

HasarAli commented 2 years ago

@yuchenshi I just opened an issue

MrAlek commented 1 year ago

Any update on this issue? It's been 4 years. The functions shell is great but not being able to pass document references as parameters is a huge limitation.