Skip to content

An ORM like package which makes working with App Engine datastore entities in go a bit easier

License

Notifications You must be signed in to change notification settings

bradberger/go-aedstorm

Repository files navigation

GoDoc Build Status codecov

This is an ORM like package which makes working with App Engine datastore entities in go a bit easier. The name aedstorm stands for App Engine DataSTore ORM.

It makes working with the datastore and basic data structs quite simple.

Example

import (
	"encoding/json"
	"net/http"

	"google.golang.org/appengine"
	aedstorm "github.com/bradberger/go-aedstorm"
)

type MyData struct {
	ID, Value string
}

func myHandler(w http.ResponseWriter, r *http.Request) {

	ctx := appengine.NewContext(r)

	// Save a new entity.
	d := &MyData{ID: "foo", Value: "bar"}
	if err := aedstorm.NewModel(&d).WithContext(ctx).Save(); err != nil {
		http.Error(w, err.Error(), 500)
		return
	}

	dd := &MyData{ID: "foo"}
	if err := aedstorm.NewModel(&dd).WithContext(ctx).Load(); err != nil {
		http.Error(w, err.Error(), 500)
		return
	}

	// dd.Value  will now equal d.Value after the load.
	w.Header.Set("Content-Type", "application/json")
	json.NewEncoder(w).Encode(&dd)
}

I'm planning on adding more documentation in the future, including some more advanced interfaces which you can implement on a model, and queries, but for now this should give you an idea how easy it is to get going.

Planned improvements

  • Better documentation, more basic examples
  • More documentation around current interfaces which can be implemented
  • Add support for loading/saving related entities

About

An ORM like package which makes working with App Engine datastore entities in go a bit easier

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages