fakegaekey

package module
v0.0.0-...-e352b95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

README

fakegaekey GoDoc wercker status GoCover

Creates a Fake Google App Engine datastore.Key. This can be used for outside scripts that need to be able to encode keys and store them.

Usage

// main.go
package main

import (
	"github.com/SeanDolphin/faekgaekey"
)


func main() {
  	context := fakegaekey.Context{AppID: "myappid", Namespace: "test"}
  	createdKey := fakegaekey.NewKey(context, "doc", "someID", 0, nil)

  	// Do something with your key


  	decodedKey, err := fakegaekey.DecodeKey("randomencodekeystring")
  	//Do something with your.
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("datastore: invalid key")

Functions

This section is empty.

Types

type Context

type Context struct {
	Namespace string
	AppID     string
}

type Key

type Key struct {
	// contains filtered or unexported fields
}

func DecodeKey

func DecodeKey(encoded string) (*Key, error)

func NewKey

func NewKey(context Context, kind, stringID string, intID int64, parent *Key) *Key

func (*Key) AppID

func (k *Key) AppID() string

AppID returns the key's application ID.

func (*Key) Encode

func (k *Key) Encode() string

func (*Key) Incomplete

func (k *Key) Incomplete() bool

Incomplete returns whether the key does not refer to a stored entity. In particular, whether the key has a zero StringID and a zero IntID.

func (*Key) IntID

func (k *Key) IntID() int64

IntID returns the key's integer ID, which may be 0.

func (*Key) Kind

func (k *Key) Kind() string

Kind returns the key's kind (also known as entity type).

func (*Key) Namespace

func (k *Key) Namespace() string

Namespace returns the key's namespace.

func (*Key) Parent

func (k *Key) Parent() *Key

Parent returns the key's parent key, which may be nil.

func (*Key) StringID

func (k *Key) StringID() string

StringID returns the key's string ID (also known as an entity name or key name), which may be "".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL