Giter Site home page Giter Site logo

horsefeather's Introduction

horsefeather

GoDoc
License

horsefeather is a Google Appengine Engine extension that adds functionality through tags to handle saving and loading datastore models differently. horsefeather as of v1.1 contains helper functions for basic manipulation of datastore operations. It operates like NDB from Python Appengine.

Installation

The import path for the package is gopkg.in/SeanDolphin/horsefeather.v1.

To install it, run:

go get gopkg.in/SeanDolphin/horsefeather.v1

Usage

Tags

package somepackage

import (
	"gopkg.in/SeanDolphin/horsefeather.v1"
	"google.golang.org/appengine/datastore"

	"time"
)

type Person struct{
	Key    		*datastore.Key
	Name 		FullName 		`datastore:"-" hf:"opaque"`			//saves this property as a json string
	Address    	*Address  		`datastore:"-" hf:"compress,crc"`	//compresses this property and calculates and crc
	AddressCRC	string			`datastore:",noindex"`				//set by horsefeather crc above
	Updated 	time.TIme 		`hf:"timestamp"`					//updated on save with current timestamp
}

func (person *Content) Load(input []datastore.Property) error {
	return horsefeather.LoadStruct(person, input)
}

func (person *Content) Save() ([]datastore.Property, error) {
	return horsefeather.SaveStruct(person)
}

type FullName struct{
	First	string
	Last 	string
}

type Address struct {
	Street  string
	City    string
	State   string
	Zipcode string
}

Helpers

Setting up is as simple as calling hfae on the context you are using.

	ctx = hfae.Set(ctx) 

The calls then work as normal calls would work except it works with memcache, datastore and a local cache in unison.

package somepackage

type Person struct{
	Key    		*datastore.Key
	Name 		FullName 						
	Updated 	time.TIme 		
}

func DoSometask(ctx context.Context){
	var person Person
	err := hs.Get(ctx, key, &person)
}

horsefeather's People

Contributors

seandolphin avatar bhostet avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

bhostet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.