Comments (7)
We are currently debating on how to best implement this. Please stay tuned.
from nodejs-firestore.
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.
firebase/firebase-js-sdk#212 answers this
from nodejs-firestore.
@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.
@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.
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.
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)
- Query class: can order by FieldPath.documentId() failed HOT 1
- Aggregation queries: "after each" hook for "no filter, explicit orderBy, document reference cursor" failed
- count queries: "after each" hook for "counts 1 document" failed
- Improve read performance by using stale reads HOT 8
- Setting Firestore databaseId HOT 2
- Client initialization: succeeds for DocumentReference.set() failed HOT 1
- count queries using aggregate api: "after each" hook for "counts with startAt, endAt and offset with DocumentReference cursor" failed
- count queries using aggregate api: "after each" hook for "counts multiple documents with filter" failed
- Aggregation queries: "after each" hook for "performs sum that is negative" failed
- Using document set function, got Error: 5 NOT_FOUND HOT 1
- Improve network latency of `runTransaction()` routine HOT 4
- Aggregation queries: "after each" hook for "performs sum only on numeric fields" failed
- FieldPath only escapes the first `\` and '`', resulting in INVALID_ARGUMENT response HOT 1
- [Firestore] `where` should use a "type safe" approach HOT 1
- Query class: can query by FieldPath.documentId() failed HOT 1
- Firestore Timestamp toMills() not working HOT 1
- Improve TS HOT 1
- When support for range and inequality filters on multiple fields in a single query and support for query explain will be added to the library? HOT 1
- Deprecation warning for servicePath can't be resolved in TypeScript. HOT 1
- Client initialization: succeeds for CollectionReference.get() failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-firestore.