SoundWave
Hi, I’m trying to do some aggregation with this adapter GitHub - elixir-mongo/mongodb: MongoDB driver for Elixir · GitHub.
I’m tring to translate this mongo query:
db.trip.aggregate([{$group: {_id : "$city.name", count: {$sum: 1}}}])
That actually works in mongo shell and bring this results:
{ “_id” : { “name” : “City1” }, “count” : 212 }
{ “_id” : { “name” : “City2” }, “count” : 1200 }
{ “_id” : { “name” : “City3” }, “count” : 789 }
{ “_id” : { “name” : “City4” }, “count” : 540 }
{ “_id” : { “name” : “City5” }, “count” : 333 }
I’m tryin’ to use Mongo.aggregate but I don’t have clear the sintax, could anyone help me with this?
The set up of the lib is ok, I have some find queries and works find and I can render the responses correctly, It’s just I cannot figure it out how do I have to write the aggregate sentences with this adapter.
Thanks in advance.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Ankhers
That should give you what you are looking for.
SoundWave
Thanks a lot!!!
this working perfectly for me. I was missing square brackets before the first level map.
cheers.