当前位置: 首页>>代码示例>>Golang>>正文


Golang Filter.Subject方法代码示例

本文整理汇总了Golang中github.com/opesun/nocrud/frame/interfaces.Filter.Subject方法的典型用法代码示例。如果您正苦于以下问题:Golang Filter.Subject方法的具体用法?Golang Filter.Subject怎么用?Golang Filter.Subject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/opesun/nocrud/frame/interfaces.Filter的用法示例。


在下文中一共展示了Filter.Subject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Update

func (c *C) Update(a iface.Filter, data map[string]interface{}) error {
	upd := map[string]interface{}{
		"$set": data,
	}
	has_files := len(c.fileBiz) > 0
	if has_files {
		ids, err := a.Ids()
		if err != nil {
			return err
		}
		err = c.moveFiles(a.Subject(), ids[0].String())
		if err != nil {
			return err
		}
		upd["$addToSet"] = eachIfNeeded(fileNames(c.fileBiz))
	}
	err := a.Update(upd)
	if err != nil {
		return err
	}
	if c.Hooks != nil {
		c.Hooks.Select("Updated").Fire(a)
		c.Hooks.Select(a.Subject() + "Updated").Fire(a)
	}
	return nil
}
开发者ID:Laller,项目名称:nocrud,代码行数:26,代码来源:file.go

示例2: New

func (c *C) New(a iface.Filter) ([]map[string]interface{}, error) {
	scheme, err := c.getScheme(a.Subject(), "Insert")
	if err != nil {
		return nil, err
	}
	return convert.SchemeToFields(scheme, nil)
}
开发者ID:crufter,项目名称:nocrud,代码行数:7,代码来源:skeleton.go

示例3: GetClosest

// Returns the closest interval on the same day to the given interval.
func (e *Entries) GetClosest(a iface.Filter, data map[string]interface{}) (*evenday.Interval, error) {
	e.getOptions(a.Subject())
	prof, err := e.db.ToId(data["professional"].(string))
	if err != nil {
		return nil, err
	}
	from := data["from"].(int64)
	length := data["length"].(int64)
	err = e.intervalIsValid(data, prof, length)
	if err != nil {
		return nil, err
	}
	tt, err := e.getTimeTable(prof)
	if err != nil {
		return nil, err
	}
	day := evenday.DateToDayName(from)
	open := tt[day]
	taken, err := e.getTaken(a, from)
	if err != nil {
		return nil, err
	}
	adv := evenday.NewAdvisor(open, taken)
	to := from + length*60
	adv.Amount(1)
	interv, err := evenday.NewInterval(evenday.DateToMinute(from), evenday.DateToMinute(to))
	if err != nil {
		return nil, err
	}
	ret := adv.Advise(interv)
	if len(ret) == 0 {
		return nil, fmt.Errorf("Can't advise you, all day is taken.")
	}
	return ret[0], nil
}
开发者ID:crufter,项目名称:nocrud,代码行数:36,代码来源:meeting.go

示例4: Insert

func (e *Entries) Insert(a iface.Filter, data map[string]interface{}) error {
	e.getOptions(a.Subject())
	from := data["from"].(int64)
	length := data["length"].(int64)
	prof, err := e.db.ToId(data["professional"].(string))
	if err != nil {
		return err
	}
	err = e.intervalIsValid(data, prof, length)
	if err != nil {
		return err
	}
	to := from + length*60
	err = e.okAccordingToTimeTable(data, from, to)
	if err != nil {
		return err
	}
	err = e.othersAlreadyTook(a, from, to)
	if err != nil {
		return err
	}
	i := map[string]interface{}{
		"createdBy":       e.userId,
		"from":            from,
		"to":              to,
		"length":          length,
		"day":             dateToString(from),
		"forProfessional": prof,
	}
	return a.Insert(i)
}
开发者ID:crufter,项目名称:nocrud,代码行数:31,代码来源:meeting.go

示例5: Edit

func (c *C) Edit(a iface.Filter) ([]map[string]interface{}, error) {
	doc, err := a.FindOne()
	if err != nil {
		return nil, err
	}
	scheme, err := c.getScheme(a.Subject(), "Update")
	if err != nil {
		return nil, err
	}
	return convert.SchemeToFields(scheme, doc)
}
开发者ID:crufter,项目名称:nocrud,代码行数:11,代码来源:skeleton.go

示例6: Login

func (a *C) Login(f iface.Filter, data map[string]interface{}) error {
	name := data["name"].(string)
	pass := data["password"].(string)
	// Maybe there could be a check here to not log in somebody who is already logged in.
	if user, err := user_model.FindLogin(f, name, pass); err == nil {
		a.client.StoreEncrypted("user", f.Subject()+"|"+user.Id().String())
	} else {
		return err
	}
	return nil
}
开发者ID:crufter,项目名称:nocrud,代码行数:11,代码来源:users.go

示例7: Update

func (b *Basics) Update(a iface.Filter, data map[string]interface{}) error {
	upd := map[string]interface{}{
		"$set": data,
	}
	err := a.Update(upd)
	if err != nil {
		return err
	}
	if b.Hooks != nil {
		b.Hooks.Select("Updated").Fire(a)
		b.Hooks.Select(a.Subject() + "Updated").Fire(a)
	}
	return nil
}
开发者ID:crufter,项目名称:nocrud,代码行数:14,代码来源:basics.go

示例8: Insert

func (b *Basics) Insert(a iface.Filter, data map[string]interface{}) (iface.Id, error) {
	id := b.Db.NewId()
	data["_id"] = id
	err := a.Insert(data)
	if err != nil {
		return nil, err
	}
	if b.Hooks != nil {
		q := map[string]interface{}{
			"_id": id,
		}
		filt := a.Clone().AddQuery(q)
		b.Hooks.Select("Inserted").Fire(filt)
		b.Hooks.Select(a.Subject() + "Inserted").Fire(filt)
	}
	return id, nil
}
开发者ID:crufter,项目名称:nocrud,代码行数:17,代码来源:basics.go

示例9: Insert

func (c *C) Insert(a iface.Filter, data map[string]interface{}) (iface.Id, error) {
	has_files := len(c.fileBiz) > 0
	if has_files {
		merge(data, fileNames(c.fileBiz))
	}
	id, err := c.Basics.Insert(a, data)
	if err != nil {
		return id, err
	}
	if has_files {
		err := c.moveFiles(a.Subject(), id.String())
		if err != nil {
			return nil, err
		}
	}
	return id, nil
}
开发者ID:Laller,项目名称:nocrud,代码行数:17,代码来源:file.go

示例10: Reduce

func (f *Filter) Reduce(a ...iface.Filter) (iface.Filter, error) {
	l := len(a)
	if l == 0 {
		return &Filter{}, fmt.Errorf("Nothing to reduce.")
	}
	var prev iface.Filter
	prev = f
	for _, v := range a {
		ids, err := prev.Ids()
		if err != nil {
			return &Filter{}, err
		}
		v.AddParents("_"+prev.Subject(), ids)
		prev = v
	}
	return prev, nil
}
开发者ID:Laller,项目名称:nocrud,代码行数:17,代码来源:filter.go


注:本文中的github.com/opesun/nocrud/frame/interfaces.Filter.Subject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。