Giter VIP home page Giter VIP logo

Comments (7)

schmidt-sebastian avatar schmidt-sebastian commented on June 8, 2024 4

We are currently debating on how to best implement this. Please stay tuned.

from nodejs-firestore.

goldensunliu avatar goldensunliu commented on June 8, 2024

I have also filed this against firebase/firebase-js-sdk#272 since I am not sure where the source of development on the firestore part is housed.

from nodejs-firestore.

goldensunliu avatar goldensunliu commented on June 8, 2024

firebase/firebase-js-sdk#212 answers this

from nodejs-firestore.

IchordeDionysos avatar IchordeDionysos commented on June 8, 2024

@goldensunliu Are you sure that that the issue in the Firebase JS SDK really answers this?
As I understood the answer from @wilhuff, is that this won't appear in the JS CLIENT SDK as you are having offline capabilities there and so on.

I don't see a problem in the ADMIN SDK to add such a method to the DocumentReference. As far as I know, there is no caching in the ADMIN SDK, so it should be no problem to allow a snippet/method like this:

admin.firestore().document("path/to/a/document").select("y").get().then(snap => {
    console.log(`snapShot only has one field ${snap.data()}`);
    // Expected output: {y: 5}
});

Or am I wrong?

from nodejs-firestore.

wilhuff avatar wilhuff commented on June 8, 2024

@IchordeDionysos you're right: the comments in firebase/firebase-js-sdk#212 specifically relate to the mobile clients and the complications of interacting with the cache while offline. These concerns do not apply to the nodejs or admin SDKs.

document(..).get() translates into a BatchGetDocumentsRequest RPC, which includes a document mask, so this should be possible to implement.

In the meantime you can work around this by writing the following instead:

const projectId = // ... your project id 
const path = 'path/to/a/document';
db.document(path)
    .parent  // i.e. the collection containing the document
    .where('__name__', '==', `projects/${projectId}/databases/(default)/documents/${path}`)
    .select(...)

Note that the result will be a query snapshot rather than a document snapshot, but it should get you what you want in the short term.

@schmidt-sebastian holler if I got this wrong.

from nodejs-firestore.

schmidt-sebastian avatar schmidt-sebastian commented on June 8, 2024

A more concise version would be as follows:

const docRef = db.doc('path/to/a/document');
docRef.parent.where(Firestore.FieldPath.documentId(), '==', docRef).select(...)

from nodejs-firestore.

triplef avatar triplef commented on June 8, 2024

It would be great to have this issue re-opened for consideration.

As mentioned above, the comments in firebase/firebase-js-sdk#212 don’t apply to the Admin SDK. It would be great to have a DocumentReference.select() function implemented there.

from nodejs-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.