This repository has been archived on 2025-03-01. You can view files and clone it, but cannot push or open issues or pull requests.
trantor/database.go
2012-08-19 02:29:34 +02:00

39 lines
730 B
Go

package main
import (
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
)
type Book struct {
Id string `bson:"_id"`
Title string
Author []string
Contributor string
Publisher string
Description string
Subject []string
Date string
Lang []string
Type string
Format string
Source string
Relation string
Coverage string
Rights string
Meta string
Path string
Cover string
CoverSmall string
Keywords []string
}
func GetBook(coll *mgo.Collection, query bson.M) ([]Book, error) {
var books []Book
err := coll.Find(query).All(&books)
for i, b := range books {
books[i].Id = bson.ObjectId(b.Id).Hex()
}
return books, err
}