Twitter OAuth + Node + A MongoDB Collection: How to store users?

I've successfully retrieved a user's id and screen name from Twitter's oauth service, like so:

{ user_id: '12345678', screen_name: 'spencergardner' }

I am hoping to create a simple way for users to authenticate using Twitter (and soon Facebook, for example), so that they can add words they are interested in learning to their account. How do I now go about setting up "users" in a mongodb collection that will allow each user to have their own bank of words (and other data)?

If I understand you correctly, you are asking how you can store data with different structures in a mongo collection.

Well, you're in luck! Mongo does just that. You can store any different data structures in a mongo collection without having to "declare" the structure a priori. Just create a DBObject (if using the Java driver for example), add fields to it, and just save it. You can then retrieve it, and query the data to see what this specific users has, and anything you want in your application.

I use mongoose with nodejs to create a user model which you would then input the oauth data into and then you would be free to associate whatever data you wanted.

Once you've obtained the Oauth information you could create a new User associating the twitter data with that specific user model. The _id is automatically provided however in this case, you would use the user_id returned from twitter (assuming that is unique).

Here's an example schema:

var mongoose = require('mongoose')
, Schema = mongoose.Schema

var userSchema = new Schema({

_id: String,
screen_name: String,
words: Array
});

module.exports = mongoose.model('User', userSchema);

In future you would be able to query the database for a particular user, and authenticate a user when they return. You would also look to create a new User with something similar to the following:

new User({    _id: req.body.user_id,
              password: req.body.screen_name,
              words: []
    }).save(function(err) {
          if (!err) {
            res.send("User added");
            }
        })