Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var UserSchema = mongoose.Schema({
- username: {
- type: String,
- index: true,
- required: true,
- unique: true
- },
- password: {
- type: String,
- required: true
- },
- email: {
- type: String,
- required: true,
- lowercase: true
- },
- emailVerified: {
- type: Boolean,
- default: false
- },
- info: {
- name: {
- givenName: String,
- familyName: String,
- },
- address: {
- street: String,
- city: String,
- state: String,
- zipCode: String
- },
- primaryPhone: String,
- cellPhone: String,
- website: String,
- licenseNumber: String,
- title: String,
- company: String
- },
- avatar: {
- type: String,
- default: '/images/avatar/default/contacts-128.png'
- },
- friends: [{ type: ObjectId, ref: User }],
- friendRequests: [{ type: ObjectId, ref: User }]
- });
- module.exports.search = function(searchValue, callback) {
- var searchValue = new RegExp(`^${searchValue}`, 'i');
- var query = {
- $or: [
- {username: searchValue},
- {email: searchValue}
- // {givenName condition here...}
- ]
- }
- User.find(query, callback).limit(10);
- }
- {info.name.givenName: searchValue}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement