示例#1
0
文件: entries.go 项目: argentum47/Fio
func (c Entries) Index() revel.Result {
	var entries []models.Entry
	coll := models.Collection(new(models.Entry), c.MongoSession)
	if err := coll.Find(nil).All(&entries); err != nil {
		panic(err)
	}
	return c.RenderJson(entries)
}
示例#2
0
文件: entries.go 项目: argentum47/Fio
func (c Entries) Create() revel.Result {
	e := models.Entry{
		Id:         bson.NewObjectId(),
		Created_at: time.Now(),
		Note:       "A note",
		Amount:     3.14,
	}
	coll := models.Collection(e, c.MongoSession)
	coll.Insert(e)
	return c.RenderJson(ApiResponse{})
}