Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing firebase.firestore.FieldPath #139

Open
cruzdanilo opened this issue Mar 27, 2019 · 1 comment · May be fixed by #140
Open

missing firebase.firestore.FieldPath #139

cruzdanilo opened this issue Mar 27, 2019 · 1 comment · May be fixed by #140

Comments

@cruzdanilo
Copy link

TypeError: firebase.firestore.FieldPath is not a constructor
@cruzdanilo
Copy link
Author

i could work it around using the following code:

const proxyquire = require('proxyquire');
const { expect } = require('chai');
const { firestore: { FieldPath } } = require('firebase-admin');
const { MockFirebaseSdk, MockFirebase, MockFirestore } = require('firebase-mock');

const auth = new MockFirebase().autoFlush();
const firestore = new MockFirestore().autoFlush();
const firebase = MockFirebaseSdk(null, () => auth, () => firestore);
firebase.firestore.FieldPath = FieldPath;
firebase.initializeApp();

const addActivities = proxyquire('../addActivities', { 'firebase-admin': firebase });

but the queries are not working (they return empty) when using special characters in the field name/path, which is the main reason for using firebase.firestore.FieldPath in the first place (reference). example:

firebase.firestore().collection('questions')
  .where(new firebase.firestore.FieldPath('tags', 'A|B'), '==', true)
  .limit(10)
  .get();

collection data:

{
  "1": {
    "body": "body",
    "choices": [
      "a",
      "b",
      "c",
      "d",
      "e"
    ],
    "tags": {
      "A": true,
      "A|B": true,
      "A|B|C": true
    }
  }
}

@cruzdanilo cruzdanilo linked a pull request Mar 27, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant