Fixed inconsistencies in code and documentation under resolvers, changed log.Remove to be a method instead of a function as well as take the posts with it.
the build was successful

This commit is contained in:
2018-07-08 12:10:06 +02:00
parent 9b705e6514
commit 6f04da49b8
8 changed files with 316 additions and 239 deletions
+18 -10
View File
@@ -86,16 +86,6 @@ func List(limit int) ([]Log, error) {
return listLog(bson.M{}, limit)
}
// Remove removes the log post with this ID. Both the long and short ID is accepted
func Remove(id string) error {
return logsCollection.Remove(bson.M{
"$or": []bson.M{
bson.M{"_id": id},
bson.M{"shortId": id},
},
})
}
// ListSearch lists the logs matching the parameters. Empty/zero values means the parameter is ingored when
// building the query. This is the old aitelogs2 way, but with the addition of a text search.
//
@@ -328,6 +318,24 @@ func (log *Log) UpdateCharacters() error {
return nil
}
// Remove removes the log and all associated posts from the database
func (log *Log) Remove() error {
err := logsCollection.Remove(bson.M{"_id": log.ID})
if err != nil {
return err
}
_, err = postCollection.RemoveAll(bson.M{"$or": []bson.M{
bson.M{"logId": log.ID},
bson.M{"logId": log.ShortID},
}})
if err != nil {
return err
}
return nil
}
func findLog(query interface{}) (Log, error) {
log := Log{}
err := logsCollection.Find(query).One(&log)