コード例 #1
0
ファイル: social.go プロジェクト: philips/gocrud
	_ "github.com/go-sql-driver/mysql"
	"github.com/gocql/gocql"
	"github.com/gocrud/api"
	"github.com/gocrud/req"
	"github.com/gocrud/store"
	"github.com/gocrud/x"
)

var storeType = flag.String("store", "leveldb",
	"Available stores are cass for cassandra, "+
		"sql for MySQL, leveldb for LevelDB, "+
		"datastore for Google Datastore. "+
		"LevelDB is the default.")

var log = x.Log("social")
var c *req.Context

type Like struct {
	Id string `json:"id,omitempty"`
}

type Comment struct {
	Id      string    `json:"id,omitempty"`
	Comment []Comment `json:"Comment,omitempty"`
	Like    []Like    `json:"Like,omitempty"`
}

type Post struct {
	Id      string    `json:"id,omitempty"`
	Comment []Comment `json:"Comment,omitempty"`
コード例 #2
0
ファイル: store.go プロジェクト: philips/gocrud
package store

import "github.com/gocrud/x"

var log = x.Log("store")

type Store interface {
	Init(string)
	Commit(tablePrefix string, its []*x.Instruction) error
	IsNew(tablePrefix string, subject string) bool
	GetEntity(tablePrefix string, subject string) ([]x.Instruction, error)
}
コード例 #3
0
ファイル: api.go プロジェクト: philips/gocrud
package api

import (
	"encoding/json"
	"errors"
	"fmt"
	"time"

	"github.com/Sirupsen/logrus"
	"github.com/gocrud/req"
	"github.com/gocrud/x"
)

var log = x.Log("api")

type Node struct {
	kind      string
	id        string
	source    string
	children  []*Node
	parent    *Node
	edges     map[string]interface{}
	Timestamp int64
}

func Get(kind, id string) *Node {
	log.WithFields(logrus.Fields{
		"func": "GetNode",
		"kind": kind,
		"id":   id,
	}).Debug("Called Get")