Firestore DeadlineExceeded exception for big collections

前端 未结 2 945
一个人的身影
一个人的身影 2021-01-02 20:06

I\'m trying to read bigger collections from Google Firestore for testing and archiving purposes. I\'m hitting some interesting errors when I try to get all documents from co

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 20:33

    After some help from the firebase support team we were able to figure out that there is indeed a bug with the python client api. There is a bugfix coming in one of the next releases. Most likely it will enable the python library to sort by documentid and therefore use start_after().

    Up until then you have two possible solutions:

    1. use another field to sort on and use start_after()

    2. use the node.js library with paging like:

    var db = admin.firestore();
    admin.firestore().settings({ timestampsInSnapshots: true });
    function readNextPage(lastReadDoc) {
      let query = db
        .collection(collection)
        .orderBy(admin.firestore.FieldPath.documentId())
        .limit(100);
    }
    

提交回复
热议问题