const mongoose = require('mongoose');
const { Schema, model } = mongoose;
mongoose.Types.ObjectId.isValid();

const userSchema = new Schema(
	{
		name: {
			type: String,
			default: null,
		},
		lastName: {
			type: String,
			default: null,
		},
		number: {
			type: String,
			required: [true, 'Number required'],
			unique: true,
			min: 8,
			max: 14,
		},
		country: {
			type: String,
			required: [true, 'Country required'],
			min: 1,
			max: 40,
		},
		avatarUrl: {
			type: String,
			default: null,
		},
		color: {
			type: String,
			default: null,
		},
		token: {
			type: String,
			default: null,
		},
		code: {
			type: String,
			default: null,
		},
		online: {
			type: String,
			default: null,
		},
	},
	{ timestamps: true }
);

const User = model('user', userSchema);

module.exports = User;
