示例#1
0
	CreatedAt time.Time `db:",omitempty"`
}

var itemsA = Table("items_a",
	sol.Column("id", Serial()),
	sol.Column("name", types.Varchar()),
)

var itemsB = Table("items_b",
	sol.Column("id", Serial()),
	sol.Column("name", types.Varchar()),
	sol.PrimaryKey("id"),
)

var itemsFK = Table("items_fk",
	sol.ForeignKey("id", itemsB, types.Integer().NotNull()),
	sol.Column("name", types.Varchar()),
)

type item struct {
	ID   uint64 `db:",omitempty"`
	Name string
}

func (i item) Exists() bool {
	return i.ID != 0
}

var meetings = Table("meetings",
	sol.Column("uuid", UUID().NotNull().Unique().Default(GenerateV4)),
	sol.Column("time", TimestampRange()),
示例#2
0
文件: sessions.go 项目: aodin/volta
		return fmt.Errorf("auth: keyless sessions cannot be deleted")
	}
	return session.manager.Delete(session.Key)
}

// Exists returns true if the session exists
func (session Session) Exists() bool {
	return session.Key != ""
}

// Sessions is the postgres schema for sessions
var Sessions = postgres.Table("sessions",
	sol.Column("key", types.Varchar().NotNull()),
	sol.ForeignKey(
		"user_id",
		Users.C("id"),
		types.Integer().NotNull(),
	).OnDelete(sol.Cascade).OnUpdate(sol.Cascade),
	sol.Column("expires", postgres.Timestamp().WithTimezone()),
	sol.PrimaryKey("key"),
)

// SessionManager is the internal manager of sessions
type SessionManager struct {
	conn    sol.Conn
	cookie  config.Cookie
	keyFunc KeyFunc
	nowFunc func() time.Time
}

// Create creates a new session using a key generated for the given User