use of com.google.cloud.firestore.WriteResult in project spring-cloud-gcp by spring-cloud.
the class FirestoreSampleApp method writeDocumentFromObject.
private void writeDocumentFromObject() throws ExecutionException, InterruptedException {
// Add document data with id "joe" using a custom User class
User data = new User("Joe", Arrays.asList(new Phone(12345, PhoneType.CELL), new Phone(54321, PhoneType.WORK)));
// .get() blocks on response
WriteResult writeResult = this.firestore.document("users/joe").set(data).get();
System.out.println("Update time: " + writeResult.getUpdateTime());
}
use of com.google.cloud.firestore.WriteResult in project spring-cloud-gcp by spring-cloud.
the class FirestoreSampleApp method writeDocumentFromMap.
private void writeDocumentFromMap() throws InterruptedException, java.util.concurrent.ExecutionException {
DocumentReference docRef = this.firestore.collection("users").document("ada");
// Add document data with id "ada" using a hashmap
Map<String, Object> data = new HashMap<>();
data.put("name", "Ada");
data.put("phones", Arrays.asList(123, 456));
// asynchronously write data
ApiFuture<WriteResult> result = docRef.set(data);
// result.get() blocks on response
System.out.println("Update time: " + result.get().getUpdateTime());
}
use of com.google.cloud.firestore.WriteResult in project spring-cloud-gcp by spring-cloud.
the class FirestoreExample method writeDocumentFromObject2.
void writeDocumentFromObject2() throws ExecutionException, InterruptedException {
// Add document data with id "joe" using a custom User class
User data = new User("Joseph", Arrays.asList(new Phone(23456, PhoneType.CELL), new Phone(65432, PhoneType.WORK)));
// .get() blocks on response
WriteResult writeResult = this.firestore.document("users/joe").set(data).get();
LOGGER.info("Update time: " + writeResult.getUpdateTime());
}
Aggregations