mikkopaderes / ember-firebase-service

Exposes a service that's a direct representation of Firebase
MIT License
4 stars 2 forks source link

Cannot read property 'arrayUnion' of undefined #22

Closed edukun closed 4 years ago

edukun commented 4 years ago

I'm trying to use the arrayUnion function of firestore, but it says that FieldValue is undefined.

firebase: service() ... this.get('firebase').firestore.FieldValue.arrayUnion(...)

I have ember-firebase-service 6.0.4 and firebase 7.7.0

mikkopaderes commented 4 years ago

I don't think that API is available in the firebase service which represents firebase.app.App. Try this:

import firebase from 'firebase';

firebase.FieldValue.arrayUnion(...);
edukun commented 4 years ago

Now it shows me this error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() If I call firebase.initializeApp(), then says that API key is invalid

edukun commented 4 years ago

Could firestore be imported directly? this is the class I need to access https://firebase.google.com/docs/reference/js/firebase.firestore.FieldValue

mikkopaderes commented 4 years ago

Sorry about that it should be firebase.firestore.FieldValue.arrayUnion(...).

And yeah, you can import firebase directly for use-cases where you need the API for firebase.

edukun commented 4 years ago

Ok, solved. Just needed to call firebase.firestore.FieldValue.arrayUnion(...) instead of this.get('firebase')