Closed GoogleSites closed 4 years ago
Hypixel uses MongoDB, it is not a relational database so there isn't a primary key to apply in the first place.
Ah gotcha, maybe upserting instead of inserting would be better as it would avoid duplicates? Seems a bit weird to return the same user twice in the member list
Upserting is not possible with the positional operator in MongoDB, so we need to $addToSet or $push. Both of which can create duplicates. We should've created a unique index on the member uuid + _id to prevent this on the database directly. However, it's quite rare, and none of our code really cares about this discrepancy, so it's not a high priority fix for us at the moment. I've gone ahead and manually fixed this guild though.
As per the docs, the list of members returned from the
/guild
endpoint should be unique (as you cannot have the same user twice in the same guild). I was investigating a duplicate key insertion error and it turns out this is not always true.Example:
https://api.hypixel.net/guild?name=The%20Illumination
The member
ba336ded5a5f4b01a45aa03fdb55d3d1
is present in themembers
array twice, with all identical data exceptjoined
, where the timestamp difference is 30 milliseconds. I'm not really sure what happened here but this seems like a bug in your internal storing/database sharding? Weird how the primary key isn't set on the guild uuid and user uuid anyhow.Let me know if I did anything wrong, thanks!