DionChen / vertx-x4-koltin-coroutines

0 stars 0 forks source link

possible mongo group stage error #1

Closed guyspy closed 3 years ago

guyspy commented 3 years ago

Hi there, 我是電獺這邊的主考官豬排 以下這段我有疑問

https://github.com/DionChen/vertx-x4-koltin-coroutines/blob/c7f3f1520fa24158316dc2acd884668d9a0b98f4/src/main/kotlin/movierating/App.kt#L112-L116

其中的 "_id", "avg" 感覺應該不會正常運作?

DionChen commented 3 years ago

你好, 針對你的問題 我提供轉換後的JSON與執行結果給你看 JSON : [{"$match":{"MOVIE_ID":"indianajones"}},{"$group":{"_id":"avg","value_avg":{"$avg":"$VALUE"}}}]

查詢結果 [image: image.png]

guyspy @.***> 於 2021年3月25日 週四 上午10:20寫道:

Hi there, 我是電獺這邊的主考官豬排 以下這段我有疑問

https://github.com/DionChen/vertx-x4-koltin-coroutines/blob/c7f3f1520fa24158316dc2acd884668d9a0b98f4/src/main/kotlin/movierating/App.kt#L112-L116

其中的 "_id", "avg" 感覺應該不會正常運作?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DionChen/vertx-x4-koltin-coroutines/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDHC5JMUCWTBNGX4Q5TMRDTFKMWLANCNFSM4ZYOHREA .

guyspy commented 3 years ago

sorry

查詢結果
[image: image.png]

圖片上傳似乎失敗了

DionChen commented 3 years ago

執行結果如下: curl http://localhost:8080/getRating/indianajones {"id":"indianajones","rating":5} curl http://localhost:8080/getRating/starwars {"id":"starwars","rating":6}

guyspy @.***> 於 2021年3月25日 週四 上午10:36寫道:

sorry

查詢結果

[image: image.png]

圖片上傳似乎失敗了

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DionChen/vertx-x4-koltin-coroutines/issues/1#issuecomment-806318125, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDHC5KZJQPNCEBAWEZKFILTFKOTDANCNFSM4ZYOHREA .

guyspy commented 3 years ago

OK 好的,看來會動那沒問題 其實語法上比較標準是 _id:null 因為我們是要把 $match 拿到的東西全部合起來算,不用再切分

若要再切的話 ,會用 _id:'$field_name' 的語法

DionChen commented 3 years ago

感謝你的建議 另外做這個Api時,我有想到mongodb的特性是不用schema的 所以理論上來說POST 跟PUT 應支援對欄位的新增,但依照你們題目的需求是只要有原本的功能即可,所以沒把這項功能加至我改寫的Api中

guyspy @.***> 於 2021年3月25日 週四 上午11:10寫道:

OK 好的,看來會動那沒問題 其實語法上比較標準是 _id:null 因為我們是要把 $match 拿到的東西全部合起來算,不用再切分

若要再切的話 ,會用 _id:'$:field_name' 的語法

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DionChen/vertx-x4-koltin-coroutines/issues/1#issuecomment-806330783, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDHC5KZNP2YHQSMUNFH5ALTFKSQTANCNFSM4ZYOHREA .

DionChen commented 3 years ago

在此申明一下,不是沒想到這方面的問題

陳明宣 @.***> 於 2021年3月25日 週四 上午11:16寫道:

感謝你的建議 另外做這個Api時,我有想到mongodb的特性是不用schema的 所以理論上來說POST 跟PUT 應支援對欄位的新增,但依照你們題目的需求是只要有原本的功能即可,所以沒把這項功能加至我改寫的Api中

guyspy @.***> 於 2021年3月25日 週四 上午11:10寫道:

OK 好的,看來會動那沒問題 其實語法上比較標準是 _id:null 因為我們是要把 $match 拿到的東西全部合起來算,不用再切分

若要再切的話 ,會用 _id:'$:field_name' 的語法

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DionChen/vertx-x4-koltin-coroutines/issues/1#issuecomment-806330783, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDHC5KZNP2YHQSMUNFH5ALTFKSQTANCNFSM4ZYOHREA .

guyspy commented 3 years ago

沒錯,只要原本功能即可,感謝回應。