IIC2173-2015-2-Grupo2/news-api

View on GitHub
models/tag.go

Summary

Maintainability
A
1 hr
Test Coverage
package models

import (
    "github.com/jmcvetta/neoism"
)

/*
Tag model
*/
type Tag struct {
    ID   int64  `json:"id"`
    Name string `json:"name"`
}

// ---------------------------------------------------------------------------

/*
GetTags returns collection of news
*/
func GetTags(db *neoism.Database) (*[]Tag, error) {
    var tags []Tag
    if err := db.Cypher(&neoism.CypherQuery{
        Statement: `MATCH (tag:Tag)
                RETURN DISTINCT ID(tag) as id, tag.name as name`,
        Result: &tags,
    }); err != nil {
        return nil, err
    }
    return &tags, nil
}