Created
November 20, 2019 09:39
-
-
Save frikky/bf670cfc8b4c956dd1d0ff5a08b6a9de to your computer and use it in GitHub Desktop.
As you can see, this is way less code than rollback.go
This file contains 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
import "github.com/frikky/firestore-rollback-go" | |
// This is our self-defined fields. | |
// FirestoreEvent.Value.Fields = User | |
type User struct { | |
Username rollback.StringValue `json:"userId"` | |
Email rollback.StringValue `json:"email"` | |
DateEdited rollback.IntegerValue `json:"date_edited"` | |
} | |
// Handles the rollback of any previous document | |
func handleRollback(ctx context.Context, e FirestoreEvent) error { | |
// writtenData, firestoreReturn, err := | |
_, _, err := rollback.Rollback( | |
ctx, | |
client, // Your firestore client | |
e.OldValue.Name, // The path to roll back | |
e.OldValue.Fields, // The parsed data you have | |
) | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment