Created
October 17, 2018 16:39
-
-
Save shsunmoonlee/6bed04b1e2f8c8c2359ed91daa784e86 to your computer and use it in GitHub Desktop.
User Schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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