Code Monkey home page Code Monkey logo

Comments (24)

MattReidArnold avatar MattReidArnold commented on July 25, 2024 10

@kienner-philippe and @garciapd, I was able to get around this by making my own copy of the script and modifying the query to use collectionGroups.

Changed this:
https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/scripts/import/src/index.ts#L188

To this:

    let query = firebase
      .firestore()
      .collectionGroup(sourceCollectionPath)
      .limit(batch);

Added these to my package.json:

"devDependencies": {
    "@firebaseextensions/firestore-bigquery-change-tracker": "^1.0.0",
    "@google-cloud/bigquery": "^4.4.0",
    "inquirer": "^7.0.0",
}

Then I just run my local version of the script using ts-node with something like this:

GOOGLE_APPLICATION_CREDENTIALS="./secrets/service-account-key.json" \
    npx ts-node ./bin/firestore-bigquery-export-backfill.ts  # my local version of the file

when the script asks:

What is the path of the the Cloud Firestore Collection you would like to import from?

Give it the sub-collection name for the collection group query.
posts

from extensions.

liberathor avatar liberathor commented on July 25, 2024 7

please support sub collections!!

from extensions.

jttaynton avatar jttaynton commented on July 25, 2024 5

This is a great tool but definitely need a way to be able to do wildcards and collection groups would be good to. I have a small dataset so for now I'm going to cheat and just run updates on my existing records.

from extensions.

osheari1 avatar osheari1 commented on July 25, 2024 3

Hey, is this feature still not being worked on? I have a fix for it and can open a pull request if it's not been implemented yet.

from extensions.

russellwheatley avatar russellwheatley commented on July 25, 2024 2

I don't think that will work, @crablab. Wildcards are not supported in Firestore collection queries. You would have to target each collection individually.

from extensions.

fredzqm avatar fredzqm commented on July 25, 2024 1

Thanks for the feedback. This is not yet supported because we do not yet have a way to translate wild card path into a Firestore query. Wildcard are supported in triggers by default.

A low-hanging fruit might be adding support for collection group in the import script. Will that solve your use case?

from extensions.

russellwheatley avatar russellwheatley commented on July 25, 2024 1

@osheari1 If you have a fix for it then you're more than welcome to open a PR. I closed the issue because wildcard paths are not yet supported as a Firestore query, and a work around solution was merged in.

from extensions.

fasteater avatar fasteater commented on July 25, 2024 1

wild card is one thing, unable to import sub collection is a bigger issue. I wasn't able to implement the hacking script method, could you please support sub collections?

from extensions.

Infinitism avatar Infinitism commented on July 25, 2024 1

@russellwheatley thanks! Took care of it the way you recommended:)

from extensions.

levibn123 avatar levibn123 commented on July 25, 2024

Thanks. I realized this after looking at the code and the way imports were being made. I was able to work around this problem by using CollectionGroup and importing subcollections. For me that was extremely necessary.

from extensions.

skupsala avatar skupsala commented on July 25, 2024

A low-hanging fruit might be adding support for collection group in the import script. Will that solve your use case?

That would be great!

from extensions.

kienner-philippe avatar kienner-philippe commented on July 25, 2024

Same issue here with sub-collections.
As I have only few "chatid"s I thought I can just run the import script for each of my chatid by entering
chats/myChatId/posts as a collection path.
Same error message.
So, how could I import a sub-collection?

Hope I was clear...
Thanks in advance for your help.

from extensions.

garciapd avatar garciapd commented on July 25, 2024

Hi, any suggestion to import a sub-collection? like the proposed one chats/myChatId/posts??

from extensions.

garciapd avatar garciapd commented on July 25, 2024

Thanks @MattReidArnold !! it does work ;)

from extensions.

mohamedaboelmagd avatar mohamedaboelmagd commented on July 25, 2024

@kienner-philippe and @garciapd, I was able to get around this by making my own copy of the script and modifying the query to use collectionGroups.
......
Give it the sub-collection name for the collection group query.
posts

I don't find this file in my node modules folder
https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/scripts/import/src/index.ts#L188
where can I found it?

from extensions.

mohamedaboelmagd avatar mohamedaboelmagd commented on July 25, 2024

solve it by
"install-fs-bq-import-collection": "mkdir /.npm-global && npm config set prefix '/.npm-global' && export PATH=~/.npm-global/bin:$PATH && source /.profile && npm i -g @firebaseextensions/fs-bq-import-collection && NPM_CONFIG_PREFIX=/.npm-global",
"import-collection": "sudo /home/mohamed/.npm-global/lib/node_modules/@firebaseextensions/fs-bq-import-collection/lib/index.js"

install-fs-bq-import-collection

let query = firebase
  .firestore()
  .collectionGroup(sourceCollectionPath)
  .limit(batch);

npm run import-collection

** note: change home/mohamed/.npm-global to your username

from extensions.

johnson-yeap avatar johnson-yeap commented on July 25, 2024

Hey @osheari1, do you have the fix? It would be great if you could share with us. =D

from extensions.

Infinitism avatar Infinitism commented on July 25, 2024

Can someone explain how to implement this workaround for importing/back filling sub collections using google cloud shell please?

from extensions.

Infinitism avatar Infinitism commented on July 25, 2024

@russellwheatley : What's the work around that you say was merged in?

from extensions.

russellwheatley avatar russellwheatley commented on July 25, 2024

Hi @Infinitism, I was mistaken, I thought support for collectionGroup queries was already implemented. I've created a PR to support collectionGroupqueries, although it's not certain when or if it will be merged. If you're really keen, I'd suggest cloning the repository, and running the script locally using the changes from this PR #354.

from extensions.

crablab avatar crablab commented on July 25, 2024

This is potentially tangential, but it doesn't appear that the tool supports exporting all the collections (unless I'm doing something wrong!). I've tried *, / and simply leaving the field blank, but this doesn't seem to be covered in the documentation, and thus I assume it is not supported?

from extensions.

goleary avatar goleary commented on July 25, 2024

This seems like a supremely necessary capability of this extension/import script.

Thanks for the workaround @MattReidArnold

from extensions.

jhuleatt avatar jhuleatt commented on July 25, 2024

@russellwheatley think we can close this out now that we've merged and published #354 ?

from extensions.

russellwheatley avatar russellwheatley commented on July 25, 2024

@jhuleatt Yes, agreed.

from extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.