Get password via MongoDB
-
Do you mean the password hash? The password is not stored in the database, nor anywhere else.
-
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})
-
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})