#MongoDB help

9 messages · Page 1 of 1 (latest)

untold sparrow
#
select u.`rank`
from
    (select usr.user_id, usr.guild_id, rank() over (order by usr.total_xp desc) `rank` from users usr) u
where u.user_id=123 and u.guild_id=234
``` what could be the equivalent `MongoDB` query of this mysql syntax? sorry I'm not used to mongodb ;-;
lavish cloak
#

You can look here for a comparison of SQL and MongoDB query syntax.

untold sparrow
#

alright thanks i’ll look into it tomorrow

untold sparrow
#

how to match _id in aggregate? sql $match: { _id: { userId: 654394128108355594, guildId: 713809761925070861 } } doesn't work

lavish cloak
#

Test this:

$match: {
   "_id.userId": 654394128108355594,
   "_id.guildId": 713809761925070861
}
untold sparrow
#

nope didn't work

lavish cloak
#

Which libary you use to query MongoDB and how looks a sample entry of your data?

untold sparrow
#

um I was using MongoDB with Spring boot application and I was executing the queries in Intellij IDE's mongodb console (or playground?).

[
  {
    "_id": {
      "userId": 726189004315295804,
      "guildId": 713809761925070861
    },
    "_class": "me.srin.userbot.database.Users",
    "cooldown": 0,
    "level": 0,
    "name": "srin",
    "totalXp": 0,
    "trainingChannel": 0,
    "trainingCount": 2,
    "xp": 0,
    "xpLimit": 100
  }
]``` this is what a document looks like