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,
		},
		originalName: {
			type: String,
			default: null,
		},
		originalLastName: {
			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,
		},
		avatarsArr: {
			type: Array,
			default: [],
		},
		color: {
			type: String,
			default: null,
		},
		token: {
			type: String,
			default: null,
		},
		code: {
			type: String,
			default: null,
		},
		online: {
			type: String,
			default: null,
		},
		sort: {
			type: Boolean,
			default: false,
		},
		nightMode: {
			type: Boolean,
			default: false,
		},
	},
	{ timestamps: true }
);

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

module.exports = User;
