MongoDB Structure
-
Hiya,
I'm currently making an external application/plugin (that will not run on the forums) that will work with the forums, and sync forum profiles with in-game profiles.
We are currently using MongoDB for our game-server storage and data, therefore have opted to use MongoDB for the forums too.
My main question is, we are looking for player's of our game-server to be able to dynamically register in-game with their email and a password, and it will then insert a document with that data into the collection.
However, I have seen no documentation on the collection structure, or even database structure.
Upon looking at the database from the command line, I can only see search queries and a collection called 'objects', when looking at that collection, it was honestly un-readable.Any help would be appreciated.
Kind regards,
- James
-
If i'm not wrong mongodb structure isimplemented in a redis like manner following the key-value approach.
The reason of that is that nodebb development started with redis db as de persistanxe layer and the mongodb structure nowadays reflects that layer compromise. -
Hi,
I'm adding also support nodebb using mongodb. I'm facing similar issue retrieving a member profile to synch in my multiplayer texas hold'em game. I got authentication using blowfish working but I also need to grab user gravatar/avatar link to display in game. Thanks for the link, I take a look. It should be a matter of days once I got the info I need to get the demo up using nodebb.
/LR
-
You should be able to see some info, don't recall where I see the data, check for sessions instead of objects.
I have something on my end like below:
...
{ "_id" : ObjectId("55780ca7c711a4ad359e5f2c"), "_key" : "user:1", "banned" : 0,
"birthday" : "", "email" : "[email protected]", "fullname" : "",
"gravatarpicture" : "https://secure.gravatar.com/avatar/f3224ceb7bc2fa75df32e872812868e1?size=128&default=identicon&rating=pg",
"joindate" : 1433930919489, "lastposttime" : 1433930920619, "location" : "",
"password" : "$2a$12$5I2.pZLinAWQpXkhZzP2gumHg.nF9BurcE5eNkO1jXZAr6AUwS1lq", "passwordExpiry" : 0,
"picture" : "https://secure.gravatar.com/avatar/f3224ceb7bc2fa75df32e872812868e1?size=128&default=identicon&rating=pg",
"postcount" : 1, "profileviews" : 0, "reputation" : 0, "signature" : "", "status" : "online", "topiccount" : 1, "uid" : 1,
"uploadedpicture" : "", "username" : "LuckyRiver", "userslug" : "luckyriver", "website" : "" }
...Now, I have to figure out how programmatically retrieve that!
-
Here how I figure out to get the member profile. Assuming looking for a particular user name, if you run the following query on mongo client command line:
db.objects.find( { username: "LuckyRiver" }, { _id: 0, _key: 0, banned: 0, birthday: 0, fullname: 0, joindate: 0, lastposttime: 0, passwordExpiry: 0, profileviews: 0, signature: 0, topiccount: 0, uploadedpicture: 0, userslug: 0, website: 0, reputation:0, status: 0, location:0, username:0 } )
It will return the result of the member if found, I'm skipping all the unwanted fields .
Hope it helps!
-
You should also consider using the _key field instead of the username, since the username can change.
Store the _key value on your game when you do authentication and lookup {_key: "user:" + thevalue}
Of course, you won't need to do this if you only need to fetch the data once.
-
@yariplus said:
You should also consider using the _key field instead of the username, since the username can change.
Store the _key value on your game when you do authentication and lookup {_key: "user:" + thevalue}
Of course, you won't need to do this if you only need to fetch the data once.
I thought of that but uid was enough for my need and username was a requirement since to authenticate username and password are submitted which I retrieve to authenticate the user, first , I'm looking at username to get the hashed password which I compare with the one the user entered and apply the bcrypt algorithm. I could have use the _key but uid was also as good as _key and I don't need to do extra parsing. You're right the username may change but _key and uid won't.
-
Somehow I did need the _key when query avatar, using uid did not go well, so it's a mix of the 2, I'm using _key combining with _key:user:String.valueOf(uid)! Everything works like a charm!