mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 21:09:45 +08:00
38 lines
740 B
JavaScript
38 lines
740 B
JavaScript
'use strict';
|
|
|
|
const mongoose = require('../mongoose');
|
|
const uuid = require('uuid');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const UserProfileSchema = new Schema({
|
|
id: {
|
|
type: String,
|
|
default: uuid.v4,
|
|
unique: true
|
|
},
|
|
display_name: String,
|
|
auth_user_id: String
|
|
},{
|
|
_id: false,
|
|
timestamps: {
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Finds a user by the id.
|
|
* @param {String} id identifier of the user (uuid)
|
|
*/
|
|
UserProfileSchema.statics.findById = function(id) {
|
|
return UserProfile.findOne({id});
|
|
};
|
|
|
|
// TO DO: methods
|
|
// modifications to user as statics
|
|
// find by auth user id
|
|
|
|
const UserProfile = mongoose.model('UserProfile', UserProfileSchema);
|
|
|
|
module.exports = UserProfile;
|