Coder Social home page Coder Social logo

Comments (2)

suztomo avatar suztomo commented on June 24, 2024

Initial Attempt failed

Initial attempt that avoids modifying rootParent until updateData and setData failed.
suztomo@3ed76fe#diff-855d1299f8d5526ef0aacc2ddf24af06R28

This attempt fails to record subcollection whose parent is not saved.
cloud_firestore_mocks internally maintains documents as a tree using Map. When parent is not saved, getting collection reference creates a new map which does not have the subcolleciton.

This issue requires to save whether a document is stored in the instance or not. Maybe MockFirestoreInstance remembers all saved document location such as /users/t1gVCkBrgMU9LjFRnrtu1FFjlir1/persons/FkHWNY0ISMz9Zia0mF0q and MockDocumentReference and MockCollectionReference remembers MockFirestoreInstance.

from fake_cloud_firestore.

suztomo avatar suztomo commented on June 24, 2024

Note. In real Firestore, creating a non-top-level document does not create its parent document. For example, creating users/abc/friends/{documentId} does not create a document at users/abc.

    final firestore = Firestore.instance;
    await firestore.collection('dummy').document('abc')
    .collection('friends').document().setData(
      <String, dynamic>{
        'name': 'Tomo',
      }
    );

    final abcSaved = await firestore.collection('dummy').document('abc').get();
    if (abcSaved.exists) { // This is false.
      print('$abcSaved');
    }

from fake_cloud_firestore.

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.