Skip to content

Instantly share code, notes, and snippets.

@shsunmoonlee
Created October 17, 2018 16:39
Show Gist options
  • Select an option

  • Save shsunmoonlee/6bed04b1e2f8c8c2359ed91daa784e86 to your computer and use it in GitHub Desktop.

Select an option

Save shsunmoonlee/6bed04b1e2f8c8c2359ed91daa784e86 to your computer and use it in GitHub Desktop.
User Schema
// users-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
const user = new mongooseClient.Schema({
email: {type: String, unique: true},
username: String,
roles: [String],
photos: [{url: String, isDefault: Boolean}],
password: { type: String },
avatar: String,
facebookId: { type: String },
facebook: { type: mongooseClient.Schema.Types.Mixed },
googleId: { type: String },
google: { type: mongooseClient.Schema.Types.Mixed },
createdAt: { type: Date, 'default': Date.now },
updatedAt: { type: Date, 'default': Date.now },
posts: [{ type: mongooseClient.Schema.Types.ObjectId, ref: 'Post' }],
comments: [{ type: mongooseClient.Schema.Types.ObjectId, ref: 'Comment' }]
}, {
timestamps: true
});
return mongooseClient.model('User', user);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment