Get user data from a custom field
-
I've added to user hash a custom field where my plugin based on nodebb-plugins-login-mysite store the user remote uid.
I've to get user data using the remoteid custom field, i've take a look to https://github.com/NodeBB/NodeBB/blob/v1.10.x/src/controllers/user.js#L64 but i don't understand how i can do. -
I need it to know too?
I ask it here because it's the first google page. It would be helpful if you find the answer in a top rated topic.
I try to get the user object via
DiscordId
from a PluginI tried following but is does not work:
var user = db.getObjectField('DiscordId', message.author.id, function(err, data){ console.log(err); console.log(data); });
Output:
null null
-
I suggest taking a look at https://github.com/julianlam/nodebb-plugin-session-sharing/blob/master/library.js.
You need to store a mapping from remote uid to nodebb uid that way you can grab nodebb uid using the remote id and then grab the user data. https://github.com/julianlam/nodebb-plugin-session-sharing/blob/master/library.js#L130-L141
-
DiscordId
is already stored in user's database object.Is there no way in NodeBB to just search for a
key
-value
pair and return the whole object were the pair was found?like:
var user = db.getObject(key, value, function(err, userObject){ if(err){ console.log(err); } return userObject; });
I'm a noob and I don't understand how I can map something from a already existing field / data. I don't understand it and unfortunately I don't have the experience...
I am currently programming a lot of small plugins and it would often have been helpful to just look for a key value pair like the one mentioned above. So I always got to my goal via a lot of detours and unsightly code.
If the search for a key value pair were possible, it would make a lot of things easier for me.
-