feat: implement mongo APIs
This commit is contained in:
@@ -96,7 +96,7 @@ func (r *TranscriptionRepo) GetBySlug(ctx context.Context, slug string) (*Transc
|
||||
func (r *TranscriptionRepo) GetByYear(ctx context.Context, year int) ([]TranscriptionSummaryDoc, error) {
|
||||
filter := bson.M{"year": year, "isPublished": true}
|
||||
opts := options.Find().
|
||||
SetSort(bson.M{"month": 1, "day": 1}).
|
||||
SetSort(bson.D{{Key: "month", Value: 1}, {Key: "day", Value: 1}}).
|
||||
SetProjection(transcriptionSummaryProjection)
|
||||
cursor, err := r.col.Find(ctx, filter, opts)
|
||||
if err != nil {
|
||||
@@ -113,7 +113,7 @@ func (r *TranscriptionRepo) GetByYear(ctx context.Context, year int) ([]Transcri
|
||||
func (r *TranscriptionRepo) GetByPlace(ctx context.Context, place string) ([]TranscriptionSummaryDoc, error) {
|
||||
filter := bson.M{"place": place, "isPublished": true}
|
||||
opts := options.Find().
|
||||
SetSort(bson.M{"year": 1, "month": 1, "day": 1}).
|
||||
SetSort(bson.D{{Key: "year", Value: 1}, {Key: "month", Value: 1}, {Key: "day", Value: 1}}).
|
||||
SetProjection(transcriptionSummaryProjection)
|
||||
cursor, err := r.col.Find(ctx, filter, opts)
|
||||
if err != nil {
|
||||
@@ -130,7 +130,7 @@ func (r *TranscriptionRepo) GetByPlace(ctx context.Context, place string) ([]Tra
|
||||
func (r *TranscriptionRepo) GetByType(ctx context.Context, docType string) ([]TranscriptionSummaryDoc, error) {
|
||||
filter := bson.M{"type": docType, "isPublished": true}
|
||||
opts := options.Find().
|
||||
SetSort(bson.M{"year": 1, "month": 1, "day": 1}).
|
||||
SetSort(bson.D{{Key: "year", Value: 1}, {Key: "month", Value: 1}, {Key: "day", Value: 1}}).
|
||||
SetProjection(transcriptionSummaryProjection)
|
||||
cursor, err := r.col.Find(ctx, filter, opts)
|
||||
if err != nil {
|
||||
@@ -199,7 +199,7 @@ func (r *TranscriptionRepo) Count(ctx context.Context) (int64, error) {
|
||||
func (r *TranscriptionRepo) GetAdjacent(ctx context.Context, slug string, year int) (*TranscriptionSummaryDoc, *TranscriptionSummaryDoc, error) {
|
||||
filter := bson.M{"year": year, "isPublished": true}
|
||||
opts := options.Find().
|
||||
SetSort(bson.M{"month": 1, "day": 1}).
|
||||
SetSort(bson.D{{Key: "month", Value: 1}, {Key: "day", Value: 1}}).
|
||||
SetProjection(transcriptionSummaryProjection)
|
||||
cursor, err := r.col.Find(ctx, filter, opts)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user