It is used by nodebb socket.io dependencies.
Get password via MongoDB
-
Hi, i have a question. How to get only password for specific user via mongodb? I read arictle "Database Structure", but whatever can't understand.
-
Do you mean the password hash? The password is not stored in the database, nor anywhere else.
-
@yariplus yep, I meant password hash. How get password hash for a user?
-
db.objects.find({_key:"user:1"});
-
A bit of explanation here. NodeBB was not originally designed for mongodb, thus does not use mongo collections. Every object is stored in one large "objects" collection, and is indexed by a unique string stored in the
_key
field. For user objects this key isuser:UID
, where UID is the user's identifier.If you wanted to look up just the password field (the password hash), you can use query projection as such:
db.objects.find({_key:"user:1"}, {password: true, _id: false})
and you can add other fields as such:
db.objects.find({_key:"user:1"}, {password: true, uid: true, email: true, username: true, _id: false})
-
@yariplus oh, that's what I was looking for. Thank you!
-
Sorry, but I have another question. Can i do a query that is show all users and their password hashes?
-
Sure. You can use regular expression syntax instead of a string to match all users.
db.objects.find({_key: /^user:\d+$/}, {password: true, username: true, _id: false})
-
Oh, thanks a lot for your helping.