Changed characters graphql query to use the filter format, changed description for files query to match the others'
the build was successful
the build was successful
This commit is contained in:
@@ -154,6 +154,29 @@ func ListIDs(ids ...string) ([]Character, error) {
|
||||
return list(bson.M{"_id": bson.M{"$in": ids}})
|
||||
}
|
||||
|
||||
// ListFilter lists all logs matching the filters.
|
||||
func ListFilter(ids []string, nicks []string, names []string, author *string, search *string) ([]Character, error) {
|
||||
query := bson.M{}
|
||||
|
||||
if len(ids) > 0 {
|
||||
query["_id"] = bson.M{"$in": ids}
|
||||
}
|
||||
if len(nicks) > 0 {
|
||||
query["nicks"] = bson.M{"$in": nicks}
|
||||
}
|
||||
if len(names) > 0 {
|
||||
query["name"] = bson.M{"$in": names}
|
||||
}
|
||||
if author != nil {
|
||||
query["author"] = *author
|
||||
}
|
||||
if search != nil {
|
||||
query["$text"] = bson.M{"$search": *search}
|
||||
}
|
||||
|
||||
return list(query)
|
||||
}
|
||||
|
||||
// New creates a Character and pushes it to the database. It does some validation
|
||||
// on nick, name, shortName and author. Leave the shortname blank to have it be the
|
||||
// first name.
|
||||
@@ -227,5 +250,11 @@ func init() {
|
||||
if err != nil {
|
||||
log.Fatalln("init common.characters:", err)
|
||||
}
|
||||
err = collection.EnsureIndex(mgo.Index{
|
||||
Key: []string{"$text:description"},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln("init common.characters:", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user