@@ -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 })
@@ -294,15 +294,15 @@ func (poll *Poll) GetResult(ctx context.Context) ([]map[string]int, error) {
294294 pollResult := make (map [string ]int )
295295 cursor , err := Client .Database (db ).Collection ("votes" ).Aggregate (ctx , mongo.Pipeline {
296296 {{
297- "$match" , bson.D {
298- {"pollId" , pollId },
297+ Key : "$match" , Value : bson.D {
298+ {Key : "pollId" , Value : pollId },
299299 },
300300 }},
301301 {{
302- "$group" , bson.D {
303- {"_id" , "$option" },
304- {"count" , bson.D {
305- {"$sum" , 1 },
302+ Key : "$group" , Value : bson.D {
303+ {Key : "_id" , Value : "$option" },
304+ {Key : "count" , Value : bson.D {
305+ {Key : "$sum" , Value : 1 },
306306 }},
307307 },
308308 }},
@@ -329,8 +329,8 @@ func (poll *Poll) GetResult(ctx context.Context) ([]map[string]int, error) {
329329 // Get all votes
330330 cursor , err := Client .Database (db ).Collection ("votes" ).Aggregate (ctx , mongo.Pipeline {
331331 {{
332- "$match" , bson.D {
333- {"pollId" , pollId },
332+ Key : "$match" , Value : bson.D {
333+ {Key : "pollId" , Value : pollId },
334334 },
335335 }},
336336 })
0 commit comments