Skip to content
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-firestore/tre

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Native Image Firestore Sample | [source code](https://github.com/googleapis/java-firestore/blob/main/samples/native-image-sample/src/main/java/com/example/firestore/NativeImageFirestoreSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-firestore&page=editor&open_in_editor=samples/native-image-sample/src/main/java/com/example/firestore/NativeImageFirestoreSample.java) |
| Person | [source code](https://github.com/googleapis/java-firestore/blob/main/samples/native-image-sample/src/main/java/com/example/firestore/Person.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-firestore&page=editor&open_in_editor=samples/native-image-sample/src/main/java/com/example/firestore/Person.java) |
| Quickstart | [source code](https://github.com/googleapis/java-firestore/blob/main/samples/snippets/src/main/java/com/example/firestore/Quickstart.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-firestore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/Quickstart.java) |
| Listen Data Snippets | [source code](https://github.com/googleapis/java-firestore/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-firestore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java) |
| Manage Data Snippets | [source code](https://github.com/googleapis/java-firestore/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-firestore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java) |
Expand Down
2 changes: 1 addition & 1 deletion samples/native-image-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>native-image-support</artifactId>
<version>0.10.0</version>
<version>0.12.4</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@
import java.util.List;
import java.util.Map;

/**
* Sample Firestore application demonstrating basic operations.
*/
/** Sample Firestore application demonstrating basic operations. */
public class NativeImageFirestoreSample {

private static final String USERS_COLLECTION = "nativeimage_test_users";

/**
* Entrypoint to the Firestore sample application.
*/
/** Entrypoint to the Firestore sample application. */
public static void main(String[] args) throws Exception {
Instant startTime = Instant.now();
FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance();
Expand Down Expand Up @@ -79,9 +75,7 @@ static void createUserDocument(Firestore db) throws Exception {
static void createUserDocumentPojo(Firestore db) throws Exception {
CollectionReference collectionReference = db.collection(USERS_COLLECTION);
WriteResult result =
collectionReference.document()
.set(new Person("Alan", "Turing", 1912))
.get();
collectionReference.document().set(new Person("Alan", "Turing", 1912)).get();

System.out.println("Created user by POJO. Timestamp: " + result.getUpdateTime());
}
Expand All @@ -99,12 +93,11 @@ static void runSampleQueries(Firestore db) throws Exception {
runQuery(db.collection(USERS_COLLECTION).whereLessThan("born", 1900));
System.out.println("Number of users born before 1900: " + results.size());

results = runQuery(
db.collection(USERS_COLLECTION).whereGreaterThan(FieldPath.of("born"), 1900));
results =
runQuery(db.collection(USERS_COLLECTION).whereGreaterThan(FieldPath.of("born"), 1900));
System.out.println("Number of users born earlier after 1900: " + results.size());

results = runQuery(
db.collection(USERS_COLLECTION).whereEqualTo("name", "Ada"));
results = runQuery(db.collection(USERS_COLLECTION).whereEqualTo("name", "Ada"));
System.out.println("Number of users whose first name is 'Ada': " + results.size());
}

Expand All @@ -124,4 +117,4 @@ private static void printUsers(Iterable<QueryDocumentSnapshot> documents) {
document.getLong("born"));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@

import com.google.cloud.firestore.annotation.DocumentId;

/**
* Simple document object to load into Firestore.
*/
/** Simple document object to load into Firestore. */
public class Person {

@DocumentId
public String id;
@DocumentId public String id;

public String first;

Expand All @@ -37,4 +34,4 @@ public class Person {
this.last = last;
this.born = born;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ public void testRunSampleQueries() throws Exception {
assertThat(output).contains("Number of users born earlier after 1900: 0");
assertThat(output).contains("Number of users whose first name is 'Ada': 0");
}
}
}