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

Add databaseId all functions #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions lib/firestore/firestore_gateway.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class FirestoreGateway {
..collectionId = path.substring(path.lastIndexOf('/') + 1)
..pageSize = pageSize
..pageToken = nextPageToken;
var response =
await _client.listDocuments(request).catchError(_handleError);
var response = await _client
.listDocuments(
request,
options:
CallOptions(metadata: {'google-cloud-resource-prefix': database}),
)
.catchError(_handleError);
var documents =
response.documents.map((rawDocument) => Document(this, rawDocument));
return Page(documents, response.nextPageToken);
Expand Down Expand Up @@ -86,14 +91,21 @@ class FirestoreGateway {
..documentId = documentId ?? ''
..document = document;

var response =
await _client.createDocument(request).catchError(_handleError);
var response = await _client
.createDocument(
request,
options:
CallOptions(metadata: {'google-cloud-resource-prefix': database}),
)
.catchError(_handleError);
return Document(this, response);
}

Future<Document> getDocument(path) async {
var rawDocument = await _client
.getDocument(GetDocumentRequest()..name = path)
.getDocument(GetDocumentRequest()..name = path,
options: CallOptions(
metadata: {'google-cloud-resource-prefix': database}))
.catchError(_handleError);
return Document(this, rawDocument);
}
Expand All @@ -110,11 +122,21 @@ class FirestoreGateway {
request.updateMask = mask;
}

await _client.updateDocument(request).catchError(_handleError);
await _client
.updateDocument(
request,
options:
CallOptions(metadata: {'google-cloud-resource-prefix': database}),
)
.catchError(_handleError);
}

Future<void> deleteDocument(String path) => _client
.deleteDocument(DeleteDocumentRequest()..name = path)
.deleteDocument(
DeleteDocumentRequest()..name = path,
options:
CallOptions(metadata: {'google-cloud-resource-prefix': database}),
)
.catchError(_handleError);

Stream<Document?> streamDocument(String path) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firedart
description: A dart-native implementation of the Firebase Auth and Firestore SDKs.
version: 0.9.8
version: 0.9.9
homepage: https://github.com/cachapa/firedart

environment:
Expand Down