@@ -143,32 +143,32 @@ func GetClosedVotedPolls(ctx context.Context, userId string) ([]*Poll, error) {
143143
144144 cursor , err := Client .Database (db ).Collection ("votes" ).Aggregate (ctx , mongo.Pipeline {
145145 {{
146- "$match" , bson.D {
147- {"userId" , userId },
146+ Key : "$match" , Value : bson.D {
147+ {Key : "userId" , Value : userId },
148148 },
149149 }},
150150 {{
151- "$lookup" , bson.D {
152- {"from" , "polls" },
153- {"localField" , "pollId" },
154- {"foreignField" , "_id" },
155- {"as" , "polls" },
151+ Key : "$lookup" , Value : bson.D {
152+ {Key : "from" , Value : "polls" },
153+ {Key : "localField" , Value : "pollId" },
154+ {Key : "foreignField" , Value : "_id" },
155+ {Key : "as" , Value : "polls" },
156156 },
157157 }},
158158 {{
159- "$unwind" , bson.D {
160- {"path" , "$polls" },
161- {"preserveNullAndEmptyArrays" , false },
159+ Key : "$unwind" , Value : bson.D {
160+ {Key : "path" , Value : "$polls" },
161+ {Key : "preserveNullAndEmptyArrays" , Value : false },
162162 },
163163 }},
164164 {{
165- "$replaceRoot" , bson.D {
166- {"newRoot" , "$polls" },
165+ Key : "$replaceRoot" , Value : bson.D {
166+ {Key : "newRoot" , Value : "$polls" },
167167 },
168168 }},
169169 {{
170- "$match" , bson.D {
171- {"open" , false },
170+ Key : "$match" , Value : bson.D {
171+ {Key : "open" , Value : false },
172172 },
173173 }},
174174 })
@@ -293,15 +293,15 @@ func (poll *Poll) GetResult(ctx context.Context) ([]map[string]int, error) {
293293 pollResult := make (map [string ]int )
294294 cursor , err := Client .Database (db ).Collection ("votes" ).Aggregate (ctx , mongo.Pipeline {
295295 {{
296- "$match" , bson.D {
297- {"pollId" , pollId },
296+ Key : "$match" , Value : bson.D {
297+ {Key : "pollId" , Value : pollId },
298298 },
299299 }},
300300 {{
301- "$group" , bson.D {
302- {"_id" , "$option" },
303- {"count" , bson.D {
304- {"$sum" , 1 },
301+ Key : "$group" , Value : bson.D {
302+ {Key : "_id" , Value : "$option" },
303+ {Key : "count" , Value : bson.D {
304+ {Key : "$sum" , Value : 1 },
305305 }},
306306 },
307307 }},
@@ -328,8 +328,8 @@ func (poll *Poll) GetResult(ctx context.Context) ([]map[string]int, error) {
328328 // Get all votes
329329 cursor , err := Client .Database (db ).Collection ("votes" ).Aggregate (ctx , mongo.Pipeline {
330330 {{
331- "$match" , bson.D {
332- {"pollId" , pollId },
331+ Key : "$match" , Value : bson.D {
332+ {Key : "pollId" , Value : pollId },
333333 },
334334 }},
335335 })
0 commit comments