Ejemplo n.º 1
0
	_ "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"`
Ejemplo n.º 2
0
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)
}
Ejemplo n.º 3
0
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")