This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commands: | |
- exec: | |
commandLine: npm install | |
component: runtime | |
group: | |
isDefault: true | |
kind: build | |
workingDir: /project | |
id: install | |
- exec: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while : ; do | |
go run main.go & | |
fswatch -xrn1 -m inotify_monitor --event Created --event Removed --event Updated --event Renamed . | |
killall main | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package p contains a Firestore Cloud Function. | |
package p | |
import ( | |
"context" | |
"errors" | |
"fmt" | |
"log" | |
"os" | |
"strings" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package p | |
// Score represents the Score collection in Firestore | |
type Score struct { | |
Uid string | |
Name string | |
Points int | |
Details string | |
Country string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package p | |
import ( | |
"errors" | |
"fmt" | |
"strconv" | |
) | |
// FirestoreValue holds Firestore fields. | |
type FirestoreValue struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package p contains a Firestore Cloud Function. | |
package p | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"cloud.google.com/go/functions/metadata" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module cloudfunction | |
require cloud.google.com/go v0.34.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gcloud beta functions deploy newScore \ | |
--entry-point OnNewScore \ | |
--memory 256MB \ | |
--region us-central1 \ | |
--runtime go111 \ | |
--trigger-event providers/cloud.firestore/eventTypes/document.create \ | |
--trigger-resource "projects/<your-project-id>/databases/(default)/documents/Score/{id}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package p contains a Firestore Cloud Function. | |
package p | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"cloud.google.com/go/functions/metadata" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
Map<String, Object> doc = new HashMap<>(); | |
doc.put("uid", currentUser.getUid()); | |
doc.put("name", name); | |
doc.put("points", score.getTotalScore()); | |
doc.put("details", score.getDetailsToSave()); | |
doc.put("country", countryCode); | |
FirebaseFirestore db = FirebaseFirestore.getInstance(); | |
db.collection("Score") |
NewerOlder