Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR. allow DocumentReference.select similar to Query.select #272

Closed
goldensunliu opened this issue Oct 27, 2017 · 3 comments
Closed

FR. allow DocumentReference.select similar to Query.select #272

goldensunliu opened this issue Oct 27, 2017 · 3 comments

Comments

@goldensunliu
Copy link

  • Operating System version: OS X El Capitan. v 10.11.6
  • Firebase SDK version: 4.5.1
  • Firebase Product: firestore

Steps to reproduce:

I have been snooping around the source code and documentation. It seems like the only way to do apply a field mask to the result and returns only the specified subset of fields is through the Query.select method.
https://cloud.google.com/nodejs/docs/reference/firestore/0.8.x/Query#select
https://github.com/googleapis/nodejs-firestore/blob/master/src/reference.js#L1080

Is there any plan or ways to enable the same feature when getting a single document via DocumentReference? The code seems plenty of references to https://cloud.google.com/firestore/docs/reference/rest/v1beta1/DocumentMask which is used to restrict a get or update operation on a document to a subset of its fields, but I didn't have any luck tracking down usage of this in DocumentReference.get

Relevant Code:

// based on the select example at https://cloud.google.com/nodejs/docs/reference/firestore/0.8.x/Query#select
let collectionRef = firestore.collection('col');
let documentRef = collectionRef.doc('doc');

documentRef.set({x:10, y:5}).then(() => {
  return collectionRef.where('x', '>', 5).select('y').get();
}).then((res) => {
  console.log(`y is ${res.docs[0].get('y')}.`);
});
// would like to be able to also do
documentRef.select('y').get().then((snapShot) => {
  console.log(`snapShot only has one field ${snapShot}`);
  // Expected output: {y: 5}
});
@goldensunliu
Copy link
Author

I have also filed this against googleapis/nodejs-firestore#42

@merlinnot
Copy link
Contributor

merlinnot commented Oct 27, 2017

Duplicate of #212

@goldensunliu
Copy link
Author

damn I am heart broken. (tears)

@firebase firebase locked and limited conversation to collaborators Oct 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants