예제 #1
0
func collectionAndSubDocumentSelectors(query Query) (collection *Collection, selectors []string) {
	selectors = []string{}
	for collection == nil {
		collection, _ = query.(*Collection)
		selector := query.subDocumentSelector()
		if selector != "" {
			selectors = append(selectors, selector)
		}
		query = query.ParentQuery()
	}
	utils.ReverseStringSlice(selectors)
	return collection, selectors
}
예제 #2
0
func (self *sortQuery) mongoQuery() (q *mgo.Query, err error) {
	elems := []string{self.selector}
	for query := self.parentQuery; query != nil; query = query.ParentQuery() {
		s, ok := query.(*sortQuery)
		if !ok {
			break
		}
		elems = append(elems, s.selector)
	}
	utils.ReverseStringSlice(elems)
	q, err = self.parentQuery.mongoQuery()
	if err != nil {
		return nil, err
	}
	return q.Sort(elems...), nil
}