https://github.com/mercari/datastore
(AE|Cloud) Datastore Wrapper
https://github.com/mercari/datastore
appengine datastore golang
Last synced: 10 months ago
JSON representation
(AE|Cloud) Datastore Wrapper
- Host: GitHub
- URL: https://github.com/mercari/datastore
- Owner: mercari
- License: mit
- Created: 2017-11-09T02:00:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-17T08:37:22.000Z (12 months ago)
- Last Synced: 2025-04-04T03:08:13.426Z (10 months ago)
- Topics: appengine, datastore, golang
- Language: Go
- Homepage:
- Size: 1010 KB
- Stars: 215
- Watchers: 34
- Forks: 20
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Datastore Wrapper [][godoc] [](https://github.com/mercari/datastore/actions/workflows/cicd.yml)
[godoc]: https://pkg.go.dev/go.mercari.io/datastore/v2
(AppEngine | Cloud) Datastore wrapper for Go 👉
Simple.
Happy.
Respect standard library.
```
$ go get -u go.mercari.io/datastore/v2
```
see [v2 doc](https://pkg.go.dev/go.mercari.io/datastore/v2) at first.
## Feature
### DO
* Wrap `google.golang.org/appengine/datastore` and `cloud.google.com/go/datastore`
* keep key behavior
* align to `cloud.google.com/go/datastore` first
* Re-implement datastore package
* Re-implement datastore.SaveStruct & LoadStruct
* Ignore unmapped property
* Add PropertyTranslator interface
* Convert types like mytime.Unix to time.Time and reverse it
* Rename property like CreatedAt to createdAt or created_at and reverse it
* Re-implement PropertyLoadSaver
* Pass context.Context to Save & Load method
* Add retry feature to each RPC
* e.g. Retry AllocateID when it failed
* Add middleware layer
* About...
* Local Cache
* AE Memcache
* Logging
* Retry
* etc...
* Easy to ON/OFF switching
* Add some useful methods
* `aedatastore/TransactionContext`
### DON'T
* have utility functions
* support firestore
## Restriction
* `aedatastore` package
* When using slice of struct, MUST specified `datastore:",flatten"` option.
* original (ae & cloud) datastore.SaveStruct have different behaviors.
* see aeprodtest/main.go `/api/test3`
## Committers
* Masahiro Wakame ([@vvakame](https://github.com/vvakame))
## Contribution
Please read the CLA below carefully before submitting your contribution.
https://www.mercari.com/cla/
### Setup environment & Run tests
* requirements
* [gcloud sdk](https://cloud.google.com/sdk/docs/quickstarts)
* `gcloud components install app-engine-go`
* `gcloud components install beta cloud-datastore-emulator`
1. Testing in local
```
$ ./setup.sh # exec once
$ ./serve.sh # exec in background
$ ./test.sh
```
## License
Copyright 2017 Mercari, Inc.
Licensed under the MIT License.