IIC2173-2015-2-Grupo2/news-api

View on GitHub
models/location.go

Summary

Maintainability
A
1 hr
Test Coverage
package models

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

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

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

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