https://github.com/treeder/firetils
https://github.com/treeder/firetils
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/treeder/firetils
- Owner: treeder
- License: apache-2.0
- Created: 2019-10-28T17:05:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-31T15:03:14.000Z (11 months ago)
- Last Synced: 2025-08-15T02:57:28.447Z (10 months ago)
- Language: Go
- Size: 164 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Firebase utils for golang
Tools that make it easier to work with Google Cloud / Firebase's Firestore.
[](https://pkg.go.dev/github.com/treeder/firetils)
For instance:
```go
ob := &MyObject{}
err := firetils.Save(ctx, client, "myCollection", ob) // depending on interfaces on the object, it will update timestamps, call PreSave() function, etc
```
Fetching:
There's several functions here, they will all call populate into a struct and call AfterLoad().
```go
firetils.GetByID
firetils.GetOneByQuery
firetils.GetAllByQuery
```
## Data Handling
Add TimeStamped and Firestored to your objects, eg:
```go
type X struct {
firetils.Firestored
firetils.TimeStamped
firetils.IDed
}
```
You can do pre-saving and after-loading by adding `PreSave(ctx context.Context)` and/or `AfterLoad(ctx context.Context)` function to your models.
## Authentication
`Authenticate` function will validate an auth token.
Or use `firetils.FireAuth` middleware to do it automatically.