Пример #1
0
func storiesByKeys(g *cayley.Handle, keys []string) []*Story {
	stories := make([]*Story, 0, len(keys))
	it, _ := cayley.StartPath(g, keys...).Save(StoryID, StoryID).Save(StoryTitle, StoryTitle).Save(StoryDescription, StoryDescription).Save(SiteID, SiteID).BuildIterator().Optimize()
	defer it.Close()
	for cayley.RawNext(it) {
		s := Story{}
		results := map[string]graph.Value{}
		it.TagResults(results)
		s.Id = atoi(g.NameOf(results[StoryID]))
		s.Title = g.NameOf(results[StoryTitle])
		s.Desc = g.NameOf(results[StoryDescription])
		s.Site = Site(Site_value[g.NameOf(results[SiteID])])
		s.annotate()
		stories = append(stories, &s)
	}
	return stories
}
Пример #2
0
func (s Story) checkExistsTitle(g *cayley.Handle) bool {
	it, _ := cayley.StartPath(g, s.key()).Out(StoryTitle).BuildIterator().Optimize()
	defer it.Close()
	return cayley.RawNext(it)
}
Пример #3
0
func (u User) checkExists(g *cayley.Handle) bool {
	it, _ := cayley.StartPath(g, u.key()).Out(UserID).BuildIterator().Optimize()
	defer it.Close()
	return cayley.RawNext(it)
}