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

Adding FieldMask support to GetAll() #443

Merged
merged 3 commits into from
Nov 12, 2018
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Nov 9, 2018

This adds a ReadOptions argument to getAll() to allow users to specify a field mask.

I tried to keep the API useable and declared the first argument of the varargs method so that it is known the DocumentReferences have to be passed first.

Fixes: #42

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 9, 2018
* @param options.fieldMask - The subset of fields to return from a read
* operation.
*/
export function validateReadOptions(options: ReadOptions): boolean {

This comment was marked as spam.

This comment was marked as spam.

@@ -117,7 +118,7 @@ export class Transaction {

if (refOrQuery instanceof DocumentReference) {
return this._firestore
.getAll_([refOrQuery], this._requestTag, this._transactionId)
.getAll_([refOrQuery], null, this._requestTag, this._transactionId)

This comment was marked as spam.

This comment was marked as spam.

dev/src/util.ts Outdated
let documents: DocumentReference[];
let readOptions: ReadOptions|undefined = undefined;

const usesVarags = !Array.isArray(documentRefsOrReadOptions[0]);

This comment was marked as spam.

This comment was marked as spam.

dev/src/util.ts Outdated
documents = documentRefsOrReadOptions as DocumentReference[];
}
} else {
// Support an array of document references as the first argument for

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -883,7 +879,8 @@ describe('getAll() method', () => {
const overrides = {batchGetDocuments: () => stream(found('documentId'))};

return createInstance(overrides).then(firestore => {
return firestore.getAll(firestore.doc('collectionId/documentId'))
return (firestore as InvalidApiUsage)
.getAll([firestore.doc('collectionId/documentId')])

This comment was marked as spam.

This comment was marked as spam.

@gsoltis gsoltis assigned schmidt-sebastian and unassigned gsoltis Nov 10, 2018
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed. Thanks for the review.

* @param options.fieldMask - The subset of fields to return from a read
* operation.
*/
export function validateReadOptions(options: ReadOptions): boolean {

This comment was marked as spam.

@@ -117,7 +118,7 @@ export class Transaction {

if (refOrQuery instanceof DocumentReference) {
return this._firestore
.getAll_([refOrQuery], this._requestTag, this._transactionId)
.getAll_([refOrQuery], null, this._requestTag, this._transactionId)

This comment was marked as spam.

dev/src/util.ts Outdated
let documents: DocumentReference[];
let readOptions: ReadOptions|undefined = undefined;

const usesVarags = !Array.isArray(documentRefsOrReadOptions[0]);

This comment was marked as spam.

dev/src/util.ts Outdated
documents = documentRefsOrReadOptions as DocumentReference[];
}
} else {
// Support an array of document references as the first argument for

This comment was marked as spam.

@@ -883,7 +879,8 @@ describe('getAll() method', () => {
const overrides = {batchGetDocuments: () => stream(found('documentId'))};

return createInstance(overrides).then(firestore => {
return firestore.getAll(firestore.doc('collectionId/documentId'))
return (firestore as InvalidApiUsage)
.getAll([firestore.doc('collectionId/documentId')])

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants