Esempio n. 1
0
func createMultipleEvents(p *model.Project, params CreateMultipleEventParams) (interface{}, error) {
	r := repo.NewRepository(p.RepoName())
	defer r.Close()

	result := make(map[string][]RawResult)
	for event, docs := range params {
		result[event] = insertEvents(r, event, docs...)
	}

	return result, nil
}
Esempio n. 2
0
func createEvent(p *model.Project, collName string, params CreateSingleEventParams) (interface{}, error) {
	r := repo.NewRepository(p.RepoName())
	defer r.Close()

	result := insertEvents(r, collName, params)
	if result[0]["success"] == true {
		return RawResult{"created": true}, nil
	} else {
		return RawResult{"created": false}, nil
	}
}
Esempio n. 3
0
func inspectCollection(p *model.Project, name string) (interface{}, error) {
	r := repo.NewRepository(p.RepoName())
	defer r.Close()

	c := r.C(name)
	var result query.RawExpr

	if err := c.Find(nil).One(&result); err != nil {
		return nil, err
	} else {
		return inspectResult{
			Name:       name,
			Properties: docToSchema(&result),
			Url:        fmt.Sprintf("/3.0/projects/<PROJECT_ID>/events/%s", name),
		}, nil
	}
}
Esempio n. 4
0
func inspectAllCollections(p *model.Project) (interface{}, error) {
	r := repo.NewRepository(p.RepoName())
	defer r.Close()

	collectionNames, err := r.CollectionNames()
	if err != nil {
		return nil, err
	}

	results := []interface{}{}
	for _, name := range collectionNames {
		if singleResult, err := inspectCollection(p, name); err != nil {
			return nil, err
		} else {
			results = append(results, singleResult)
		}
	}

	return results, nil
}