Compare commits

..

2 Commits

Author SHA1 Message Date
7430b674f0 added bson to event type 2024-08-22 13:03:33 -04:00
6704ead115 change 'createdat' to created_at 2024-08-22 12:59:53 -04:00
2 changed files with 13 additions and 13 deletions

View File

@ -130,17 +130,17 @@ func QueryEvents(filters []relay.Filter, client *mongo.Client, databaseName stri
} }
} }
if filter.Since != nil { if filter.Since != nil {
filterBson["createdat"] = bson.M{"$gte": *filter.Since} filterBson["created_at"] = bson.M{"$gte": *filter.Since}
} }
if filter.Until != nil { if filter.Until != nil {
if filterBson["createdat"] == nil { if filterBson["created_at"] == nil {
filterBson["createdat"] = bson.M{"$lte": *filter.Until} filterBson["created_at"] = bson.M{"$lte": *filter.Until}
} else { } else {
filterBson["createdat"].(bson.M)["$lte"] = *filter.Until filterBson["created_at"].(bson.M)["$lte"] = *filter.Until
} }
} }
opts := options.Find().SetSort(bson.D{{Key: "createdat", Value: -1}}) opts := options.Find().SetSort(bson.D{{Key: "created_at", Value: -1}})
if filter.Limit != nil { if filter.Limit != nil {
opts.SetLimit(int64(*filter.Limit)) opts.SetLimit(int64(*filter.Limit))
} }

View File

@ -1,11 +1,11 @@
package relay package relay
type Event struct { type Event struct {
ID string `json:"id"` ID string `json:"id" bson:"id"`
PubKey string `json:"pubkey"` PubKey string `json:"pubkey" bson:"pubkey"`
CreatedAt int64 `json:"created_at"` CreatedAt int64 `json:"created_at" bson:"created_at"`
Kind int `json:"kind"` Kind int `json:"kind" bson:"kind"`
Tags [][]string `json:"tags"` Tags [][]string `json:"tags" bson:"tags"`
Content string `json:"content"` Content string `json:"content" bson:"content"`
Sig string `json:"sig"` Sig string `json:"sig" bson:"sig"`
} }