mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-23 17:07:13 +00:00
Compare commits
No commits in common. "7430b674f01ba2a04cfa568987fc8d5207240095" and "3ea051cb3727d35dd0d3f4c78cbdff3b00a02a8e" have entirely different histories.
7430b674f0
...
3ea051cb37
@ -130,17 +130,17 @@ func QueryEvents(filters []relay.Filter, client *mongo.Client, databaseName stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if filter.Since != nil {
|
if filter.Since != nil {
|
||||||
filterBson["created_at"] = bson.M{"$gte": *filter.Since}
|
filterBson["createdat"] = bson.M{"$gte": *filter.Since}
|
||||||
}
|
}
|
||||||
if filter.Until != nil {
|
if filter.Until != nil {
|
||||||
if filterBson["created_at"] == nil {
|
if filterBson["createdat"] == nil {
|
||||||
filterBson["created_at"] = bson.M{"$lte": *filter.Until}
|
filterBson["createdat"] = bson.M{"$lte": *filter.Until}
|
||||||
} else {
|
} else {
|
||||||
filterBson["created_at"].(bson.M)["$lte"] = *filter.Until
|
filterBson["createdat"].(bson.M)["$lte"] = *filter.Until
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := options.Find().SetSort(bson.D{{Key: "created_at", Value: -1}})
|
opts := options.Find().SetSort(bson.D{{Key: "createdat", Value: -1}})
|
||||||
if filter.Limit != nil {
|
if filter.Limit != nil {
|
||||||
opts.SetLimit(int64(*filter.Limit))
|
opts.SetLimit(int64(*filter.Limit))
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package relay
|
package relay
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
ID string `json:"id" bson:"id"`
|
ID string `json:"id"`
|
||||||
PubKey string `json:"pubkey" bson:"pubkey"`
|
PubKey string `json:"pubkey"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
Kind int `json:"kind" bson:"kind"`
|
Kind int `json:"kind"`
|
||||||
Tags [][]string `json:"tags" bson:"tags"`
|
Tags [][]string `json:"tags"`
|
||||||
Content string `json:"content" bson:"content"`
|
Content string `json:"content"`
|
||||||
Sig string `json:"sig" bson:"sig"`
|
Sig string `json:"sig"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user